Scala Cheat Sheet
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. The reference material consulted while preparing these pages is listed in the section bibliography. |
A single-page, colour-coded summary of the Scala language, written against Scala 3.10 (3.10.0, announced on 12 October
2026; JDK 17 or newer, with the differences on the 3.9 LTS line named where they matter) and checked on 2026-10-16, with
additions after Scala 3.3 labelled by release — running code with Scala CLI and sbt, basics and literals, string
interpolation, methods and their parameter kinds, optional braces and end markers, control flow and pattern matching,
tuples, classes, objects, traits, case classes, enums and the modifiers sealed, open and final, functions and currying,
the type system (bounds, variance, union and intersection types, opaque types, type lambdas and match types), givens,
using clauses, context bounds, extension methods, type classes and derives, the collection operations used most,
Option, Either, Try and Future, inline and macros, compiler flags, the Scala Toolkit libraries (MUnit, OS-Lib,
uPickle, sttp and Cask), and a strip of Scala 2 forms and their Scala 3 replacements — handy for quick memorization or as a
downloadable PDF desk reference.
For the full explanation, every option, and additional examples, see the dedicated pages:
Start here — Scala Reference.
Getting started — Getting Started & Versions, Installing Scala, Hello World & @main Methods, REPL, Worksheets & Scastie, and Scala for Java, Python & JavaScript Developers.
Syntax and fundamentals — Values, Variables & Literals, Type Hierarchy & Matchable, Strings & Interpolation, Methods & Parameters, Optional Braces & Indentation, Packages, Imports & Top-Level Definitions, and Tuples & Named Tuples.
Control structures — Conditionals & Loops, For Comprehensions, Pattern Matching, Extractors & Pattern Bindings, and Exceptions, boundary & Early Exit.
Object orientation and domain modeling — Classes & Constructors, Objects & Companions, Traits & Mixins, Inheritance: Abstract, Sealed, Open & Final, Case Classes, Enums, Algebraic Data Types & GADTs, Composition, Export & Self Types, and Annotations & Visibility.
Functional programming — Functional Programming Principles, Functions as Values, Higher-Order Functions & Closures, Partial Functions, Currying & Parameter Lists, Recursion & Tail Calls, and Laziness.
The type system — Type Inference, Generics & Bounds, Variance, Union & Intersection Types, Opaque Types & Value Classes, Structural Types, Selectable & Dynamic, Dependent & Polymorphic Function Types, Type Lambdas & Higher Kinds, and Match Types.
Contextual abstractions — Contextual Abstractions Overview, Givens & Using Clauses, Context Bounds & Deferred Givens, Extension Methods, Type Classes, Type Class Derivation, Multiversal Equality, Context Functions, and Conversions, into & Implicit Resolution.
Collections — Collections Overview, Sequences, Sets & Maps, Collection Operations, Views, Iterators & LazyList, Collection Performance & Equality, and Collections Architecture & Custom Collections.
Error handling — Option & Null Safety and Either & Try.
Concurrency — Futures & Promises and Parallel Collections & Concurrency Libraries.
Metaprogramming — Metaprogramming Overview, Inline, Compile-Time Operations, Macros: Quotes & Splices, Quoted Pattern Matching, Reflection with quotes.reflect, and Staging & TASTy Inspection.
Tooling — Scala CLI, sbt & Build Tools, IDEs, Compiler Options, Linting & Errors, Scaladoc, Scala.js & Scala Native, and Versions, Compatibility & JDKs.
Java interoperability — Using Java from Scala and Calling Scala from Java.
Testing and the Scala Toolkit — Testing with MUnit, MUnit Async, Fixtures & Other Frameworks, Property-Based Testing, Files & Processes with OS-Lib, JSON with uPickle, HTTP Client with sttp, and Web Servers with Cask.
Migration — Scala 2 & Scala 3 Compatibility, Migrating from Scala 2, Incompatibilities & Dropped Features, and Upgrading Between Scala 3 Versions.
Practice and reference — Style Guide, Domain Specific Languages, Language Evolution: SIPs, Preview & Experimental, and Release History & What’s New.
Ecosystem — Ecosystem.
References
The PDF summarizes the official documentation; each source is cited in full on the page listed above that covers it, and in the section bibliography.
-
Official Scala cheatsheet (further reading only; this cheat sheet is written from scratch in Scala 3 style)