Collections
Lists are ordered collections of values.
List Literals
Section titled “List Literals”Create a list with square brackets:
const numbers = [1, 2, 3, 4, 5]const words = ["hello", "world"]Lists can span multiple lines:
const words = [ "hello", "world", "example"]Empty Lists
Section titled “Empty Lists”Use [] to create an empty list:
const empty = []Single-Item Lists
Section titled “Single-Item Lists”const one = [1]Mixed Lists
Section titled “Mixed Lists”Lists can contain mixed values when needed:
const mixed = [1, "two", 3.0, true]println(mixed)Indexing
Section titled “Indexing”Access a list item with square brackets:
let all = regex("a\\d+").findAll("x a123 y a456")
for i in all.length() { println(all[i])}Length
Section titled “Length”Values that support length() can report their size:
const words = ["hello", "world"]println(words.length())Iterating Over List Indexes
Section titled “Iterating Over List Indexes”A common pattern is to loop over list.length() and index into the list:
const numbers = [1, 2, 3]
for i in numbers.length() { println(numbers[i])}