Immutable ordered collection.
Syntax
List(1,2,3) // l(0) l.length l :+ x
Description
List is immutable; indexing starts at 0, access is with l(0) (parentheses). :+ adds a new element and returns a NEW list. length is the number of elements.
Example
val l = List(1, 2, 3) println(l) println(l(0)) println(l.length)
Expected output
List(1, 2, 3) 1 3
When to use?
Functional data processing (map/filter/fold).