Appendices
Syntax cheat sheet (Scala 3), keywords, symbol reference, Scala version highlights, learning resources and suggested study plan (12 weeks).
Appendices
47.1 Syntax cheat sheet (Scala 3) Hard keywords: abstract case catch class def do else enum export extends false final finally for given if implicit import lazy match new null object override package private protected return sealed super then throw trait true try type val var while with yield
Soft keywords (special only in context): as derives end extension infix inline opaque open transparent using | * + - 47.3 Symbol reference function type / case arrow / by-name param context function type generator in for tuple pair ("a" -> 1) wildcard / placeholder wildcard import, varargs append / prepend binder in patterns / annotations upper / lower bound covariance / contravariance union / intersection types quote / splice 47.4 Scala version highlights redesigned collections, named/default args string interpolation, implicit classes, Futures, value classes, macros (exp.) modularization, case classes > 22 fields
Java 8 lambdas/traits compile to interfaces new collections, LazyList, Using, literal types givens/using, enums, extension methods, union/intersection types, opaque types, match types, new macros, indentation syntax
scala-cli as scala command, better errors, clause interleaving, new given syntax named tuples stable, further improvements 47.5 Learning resources
Official: docs.scala-lang.org (Scala 3 Book, Tour of Scala, Reference), Scastie (online playground)
*Programming in Scala* (5th ed., Scala 3) — Odersky, Spoon, Venners, Sommers
*Functional Programming in Scala* (2nd ed., "the red book") — Chiusano, Bjarnason, Pilquist
*Scala for the Impatient* (3rd ed.) — Cay Horstmann *Hands-on Scala Programming* — Li Haoyi
*Programming Scala* (3rd ed.) — Dean Wampler *Get Programming with Scala* — Daniela Sfregola
*Scala with Cats* — Gurnell & Welsh (free) *Practical FP in Scala* — Gabriel Volpe *Zionomicon* — De Goes & Fraser
Courses: Coursera "Functional Programming Principles in Scala" (EPFL, Odersky), Rock the JVM, Scala Center MOOCs
Practice: Exercism Scala track, Scala Exercises (scala-exercises.org), Advent of Code
Community: users.scala-lang.org, Scala Discord, r/scala, This Week in Scala, Typelevel & ZIO Discords, Scala Days / Scalar / Functional Scala conferences 47.6 Suggested study plan (12 weeks)
Install, REPL, values, strings, operators Control flow, methods, functions, type hierarchy — Part I exercises
Classes, case classes, traits, enums/ADTs Pattern matching, Option/Either/Try, collections, for-comprehensions
Errors, packages, extensions, I/O, sbt, testing — Part II exercises, Project 1
Generics/variance, givens & type classes, Scala 2 implicits Advanced types, type-level programming, recursion — Project 2
FP abstractions & Cats, metaprogramming — Project 3 Futures, Cats Effect/ZIO, streaming
Actors, Java interop, performance, Scala.js/Native, Scala 3 migration JSON, web, databases — Project 4
Spark, best practices — Project 5, 6, or 8 🎓 Final Words You've covered the whole Scala landscape: from val and pattern matching to type classes, match types, macros, effect systems, actors, and Spark. Scala rewards depth — pick a style (simple direct style, Typelevel, or ZIO), build the capstone projects, read *Programming in Scala* and the red book, and join the community. Happy hacking! 🔺
// Values
val x = 1; var y = 2; lazy val z = compute(); def f = 3
// Methods & functions
def add(a: Int, b: Int = 0): Int = a + b
val inc: Int => Int = _ + 1
def sum(xs: Int*) = xs.sum
def curried(a: Int)(b: Int) = a + b
// Classes & objects
class P(val name: String):
def hi = s"Hi $name"
object P:
def apply(n: String) = new P(n)
case class Pt(x: Int, y: Int)
trait T:
def m: Int
enum Color:
case Red, Green
enum Opt[+A]:
case Some(a: A)
case None
// Control
if a then b else c
x match
case 1 => "one"
case n: Int if n > 1 => "many"
case _ => "other"
for i <- 1 to 3 if i % 2 == 1 yield i * 2
while cond do step()
try risky() catch case e: Exception => handle(e) finally cleanup()
// Collections
List(1, 2) :+ 3; 0 :: List(1); Map("a" -> 1); Set(1); Vector(1); xs.map(_ * 2).filter(_ > 1)
// Contextual
given Ordering[P] = Ordering.by(_.name)
def sort[A: Ordering](xs: List[A]) = xs.sorted
extension (s: String) def shout = s.toUpperCase
summon[Ordering[Int]]
// Types
type Id = Int | String; opaque type Meters = Double; A & B; [A] =>> Either[String, A]