โ† Scala Programming learning path
Scala Programming ยท Module 4 of 10

Collections

Scala has rich immutable collections and powerful methods.

๐Ÿ“– Key ideas

  1. List, Vector, Set and Map are immutable by default.
  2. map, filter and foldLeft transform collections without loops.
  3. Adding to an immutable list returns a new list.
  4. Map("a" -> 1) builds a map; m.get("a") returns an Option.
  5. Mutable versions live in scala.collection.mutable.
๐Ÿ’ก Real-life example: Like photocopying a list and writing on the copy: the original stays clean for everyone else.
ListImmutable linked list
VectorImmutable indexed sequence
foldLeftCombine items from the left with a start value
->Builds a key-value pair