Ah sorry, I wasn’t quite right:
arrays are fixed-length, but mutable. So if you create an emptyArray, it can only ever have 0 elements. Similarly, an array of size 3 can only have 3 elements. But you can change the elements in the array, e.g.
myArray[1] = 2
(as long as you obey the array type).
Lists
are immutable but you can create a new list by using
plus
, which would generally be safer / preferable as you aren’t modifying the original list.
val newList = oldList.plus(1)
ImmutableLists
are less safe (something else could be modifying your list at the same time) so it’s generally preferable to use an immutable list.