Skip to main content

Array Types

In LemonScript, you can assign static types to arrays. For example:

var array: Array<Number> = [1, 2, 3]
array.push("string") # Error

To set a type to an array, you can use the following syntax:

[var | const] [name]: Array<[types]> = [value]

The types determine what types the array's elements can be. You can also nest them, for example:

var array: Array<Array<Number>> = [[1, 2], [3, 4]]