Skip to content
Kavachकवच

Lists: Making a list

● Beginner2 min

Write the items in square brackets, or start empty with a type and push.

fn main() {
    let a: [Int] = []
    a.push(3)
    a.push(1)
    const b = [3, 1, 4]
    print(a)
    print(b.len())
}

The program ran and printed:

kavach run build.kav

[3, 1]3
build.kav: Kavach code, then what running it prints

An empty list has no items to guess the type from, so write it: let a: [Int] = [].