Scala Cheat Sheet 2026
The 30 highest-yield Scala facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
- How do you mix a trait into a class in Scala? → class Foo with Bar
- What is `flatMap` used for with Scala Futures? → Chaining asynchronous operations where each step depends on the previous result
- In the REPL, how do you halt execution? → Pressing Ctrl+C
- How is pattern matching performed in Scala? → using match-case
- What is a `for-comprehension` over Futures equivalent to in Scala? → Chaining flatMap and map calls for sequential async composition
- What happens when the Scala compiler cannot find a required implicit value in scope? → It produces a compile-time error
- Which Scala collection type guarantees uniqueness of elements? → Set
- Which method on a Scala Future converts it to a blocking `Try`? → Await.ready then future.value
- What is variance in Scala generics? → How subtyping relationships of type parameters relate to subtyping of parameterized types
- What does `unapplySeq` enable compared to `unapply` in Scala extractors? → It enables variable-length sequence extraction in patterns
- What does the `filter` method do on a Scala collection? → Returns only elements satisfying a predicate
- What does `scanLeft` do in Scala compared to `foldLeft`? → scanLeft returns all intermediate accumulator values, not just the final result
- In Scala 3, what is `summon[T]` equivalent to in Scala 2? → implicitly[T]
- What does `partition` return on a Scala collection? → A tuple of two collections: elements satisfying a predicate and those that don't
- What best describes a type class in Scala? → A pattern using traits and implicits to achieve ad-hoc polymorphism
- How are anonymous functions (lambdas) defined in Scala? → (x: Int) => x + 1
- How do you pattern match a Tuple2 in Scala? → case (a, b) =>
- Which Scala method combines all elements of a collection into a single value? → fold or reduce
- Which of the following claims about a functor in Scala is incorrect? → It is a built-in construct in Scala
- How do you match on a List's head and tail in Scala? → case h :: t =>
- Which Scala feature lets you add a condition to a pattern match case? → Pattern guard using `if`
- What is an algebraic data type (ADT) in Scala? → A type formed by combining other types using sealed traits and case classes
- What is a type class in Scala? → A pattern using traits and implicits to add behavior to existing types without inheritance
- What is the `Nothing` type in Scala? → The type of exceptions; it is a subtype of every type
- How do you merge two immutable Maps in Scala? → map1 ++ map2
- What does `implicit` mean when applied to a parameter in Scala? → The compiler automatically finds and passes a matching value from implicit scope
- Can case objects be used in pattern matching in Scala? → Yes, case objects are matched by reference identity
- What does `distinct` do on a Scala Seq? → Returns only unique elements in their original order
- Which keyword is used to declare an immutable variable in Scala? → val
- What is a Scala `Future`? → A delayed computation that may complete asynchronously with a value or failure
Turn these facts into recall: