Arrays

Use square brackets as usual.

Usage

val fruits = ["apple", "banana", "cherry"]
val apple = fruits[0]

print(apple)  // apple


var numbers = [0, 1, 2, 3]

numbers[3] = 5

print(numbers[3])  // 5thp
    
Syntax error: Unexpected token `[`, expected a new line at line 2:19

Type signature

Array[String]
Array[Int]thp
    
Syntax error: There should be an identifier after a binding at line 1:5

The Array signature requires the word Array. There is no Int[] or [Int] signature, since that would cause problems with the languageā€™s grammar.