Values and Types
- val and var. val binds immutably, var mutably: and idiomatic Scala treats var as a code smell to justify.
- Type inference. Types are inferred but present: val price = 12.5 is a Double the compiler proved.
- Everything has a type. Scala’s type tree is total: even Unit (no useful value) and Nothing (no value at all) are types.
Expressions
- if as expression. if returns a value: val label = if paid then "Paid" else "Due".
- Blocks. A block’s last expression is its value: scaffolding for pure computation.
- String interpolation. The s interpolator embeds expressions: s"Hello $name": typed, checked, readable.
Functions
- def and lambdas. def declares methods; lambdas write functions inline with a fat-arrow and a body.
- First-class functions. Functions are values: parameters, returns, fields: the functional half’s foundation.
- Default and named parameters. Default and named parameters delete overload piles: calls that read as prose.
Before and after this level
- Before: Start Here: Object-Oriented Meets Functional: Scala and the JVM, Functional and Object-Oriented Design.
- Next: Level 2: Collections: Immutable Collections, Transformation Operations, Lazy and Eager Processing.
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 1: Scala Foundations cover?
Values and Types, Expressions, Functions: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Start Here: Object-Oriented Meets Functional, which covers Scala and the JVM, Functional and Object-Oriented Design.