โ Scala Programming learning pathScala Programming ยท Module 4 of 10
Collections
Scala has rich immutable collections and powerful methods.
๐ Key ideas
- List, Vector, Set and Map are immutable by default.
- map, filter and foldLeft transform collections without loops.
- Adding to an immutable list returns a new list.
- Map("a" -> 1) builds a map; m.get("a") returns an Option.
- 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