StreamsConcrete Immutable Collection ClassesListsContents


A List is a finite immutable sequence. They provide constant-time access to their first element as well as the rest of the list, and they have a constant-time cons operation for adding a new element to the front of the list. Many other operations take linear time.

Lists have always been the workhorse for Scala programming, so not much needs to be said about them here. The major change in 2.8 is that the List class together with its subclass :: and its subobject Nil is now defined in package scala.collection.immutable, where it logically belongs. There are still aliases for List, Nil, and :: in the scala package, so from a user perspective, lists can be accessed as before.

Another change is that lists now integrate more closely into the collections framework, and are less of a special case than before. For instance all of the numerous methods that originally lived in the List companion object have been deprecated. They are replaced by the uniform creation methods inherited by every collection.

Next: Streams

StreamsConcrete Immutable Collection ClassesListsContents