Immutable Collections
- List, Vector, Map. Immutable List, Vector, Set and Map are the defaults: operations return new collections.
- Persistent structures. Immutable does not mean copied: structural sharing makes new versions cheap.
- Choosing collections. List for head-heavy recursion, Vector for indexed bulk, Map for lookup: chosen by access.
Transformation Operations
- map and filter. map, filter and flatMap transform collections: pipelines that say what, not how.
- fold and reduce. foldLeft collapses a collection through an accumulator: sums, maxima, built-up results.
- groupBy. groupBy buckets by a function’s answer: reporting shapes in one call.
Lazy and Eager Processing
- Views. A view makes a pipeline lazy: elements flow one at a time, no intermediate collections.
- LazyList. LazyList materialises on demand: infinite sequences defined safely.
- Choosing laziness. Laziness is a tool, not a default: bulk transforms stay eager, huge or infinite data goes lazy.
Before and after this level
- Before: Level 1: Scala Foundations: Values and Types, Expressions, Functions.
- Next: Level 3: Classes & Traits: Classes and Objects, Traits, Composition.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Scala Level 2: Collections cover?
Immutable Collections, Transformation Operations, Lazy and Eager Processing: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 1: Scala Foundations, which covers Values and Types, Expressions, Functions.