Arrays
Arrays can be defined with the following syntax:
let array = ["Item 1", "Item 2", "Item 3"];
They can also be iterated over (see loops & recursion for more).
For example, this program utilites a for
loop.
let array = ["Item 1", "Item 2", "Item 3"];
for item in array {
println(item);
}
It outputs the following:
Item 1
Item 2
Item 3
You can also get a specific item from a list, like so:
let array = ["Item 1", "Item 2", "Item 3"];
println(array[0]);
This program will print Item 1
.