Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Array Types

The type of an array is written as Arr< … >. Between the angle brackets, the types of the array’s elements are listed. If the last element type is followed by an ellipsis, this means that the length of the array is unknown and that there can be 0, 1, or more elements of this type here. Array functions such as each(...) usually return arrays with an unknown number of elements.

ProgramTypeValueError
[]Arr<>[]
[1]Arr<Num>[1]
[1, 2, 3]Arr<Num, Num, Num>[1, 2, 3]
[1, 2, 3] each(+1)Arr<Num…>[2, 3, 4]
[1, "a"]Arr<Num, Str>[1, "a"]
[[1, 2], ["a", "b"]]Arr<Arr<Num, Num>, Arr<Str, Str>>[[1, 2], ["a", "b"]]
[1;[]]Arr<Num>[1]
[1, 2;[3, 4]]Arr<Num, Num, Num, Num>[1, 2, 3, 4]
[3, 4] =rest [1, 2;rest]Arr<Num, Num, Num, Num>[1, 2, 3, 4]
[1, 2;[1, 2] each(+2)]Arr<Num, Num, Num…>[1, 2, 3, 4]
for Arr<Any…> def f Arr<Any…> as id ok [] fArr<Any…>[]