thp-lang.org/md/learn/collections/arrays.md
2024-02-20 05:17:21 -05:00

432 B

Arrays

Use square brackets as usual.

Usage

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

print(apple)


val mut numbers = [0, 1, 2, 3]

numbers[3] = 5

print(numbers[3])  // 5

Type signature

Array[String]
Array[Int]

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