Scala 3 first steps with functional style
8 steps · about 3 h 30 min · Beginner
- Compile and run a Scala 3 program (tutorial, Scala Documentation, 15 min)
Get a working toolchain and see the minimal program structure first.
- Prefer val over var (tutorial, Scala Documentation, 20 min)
Immutability by default is the habit that makes Scala code easy to reason about.
- Use if, for and match as expressions (tutorial, Scala Documentation, 25 min)
In Scala control structures return values, which changes how you write logic.
- Define methods with clear signatures (tutorial, Scala Documentation, 20 min)
Method syntax, default parameters and extension methods come up in every file.
- Model data with case classes and enums (guide, Scala Documentation, 40 min)
Case classes and enums let the compiler check every shape your data can take.
- Write anonymous functions (guide, Scala Documentation, 20 min)
Short lambdas are the input to every collection method you will use next.
- Transform collections with map, filter and fold (guide, Scala Documentation, 40 min)
Chaining collection methods replaces most loops and is idiomatic Scala.
- Handle errors with Option and Either (guide, Scala Documentation, 30 min)
Returning failures as values keeps functions pure and composable.