Lists are immutable
Lists can be accessed by position
Lists are easily created
Foldleft is like reduce, but with an explicit starting value
You can create a list from a range
Functions over lists can use ()
instead of {}
Lists can be accessed via head, headOption and tail.
Lists can be accessed via head, headOption and tail.
Accessing List via head
is unsafe and may result in a IndexOutOfBoundsException
Nil lists are identical, even of different types
Lists can be *reduced* with a mathematical operation
Lists reuse their tails
==
tests equality (same content)
Scala Lists are quite similar to arrays which means, all the elements of a list have the same type but there are two important differences.
Scala Lists are quite similar to arrays which means, all the elements of a list have the same type but there are two important differences. First, lists are immutable, which means elements of a list cannot be changed by assignment. Second, lists represent a linked list whereas arrays are flat. The type of a list that has elements of type T
is written as List[T]
.
eq
tests identity (same object)
Lists have many useful methods
Functions over lists can use _ as shorthand
This method has been deprecated in favor of macro assertion and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assertion and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assumption and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assumption and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
Please use 'an [Exception] should be thrownBy { ... }' syntax instead
This expect method has been deprecated. Please replace all invocations of expect with an identical invocation of assertResult instead.
This expect method has been deprecated. Please replace all invocations of expect with an identical invocation of assertResult instead.
This expectResult method has been deprecated. Please replace all invocations of expectResult with an identical invocation of assertResult instead.
This expectResult method has been deprecated. Please replace all invocations of expectResult with an identical invocation of assertResult instead.