A sealed trait is a Scala trait whose permitted direct subtype cases are restricted so the compiler can check pattern-match exhaustiveness.
A sealed trait defines the top of a restricted message hierarchy. In Scala, the compiler can warn when pattern matching does not handle every permitted case. section 2.3
A wallet command protocol
A typed actor can accept a Command protocol instead of raw integers: sealed trait Command, with Increase(amount: Int) and Decrease(amount: Int) extending it. The actor pattern-matches these commands to update wallet state or stop when a limit is exceeded. section 2.3
How Akka in Action, Second Edition covers it
How deep it goes
Defines sealed traits and exhaustiveness warnings, then applies them in a wallet actor without detailing compiler internals.
Examples
Uses a wallet with Increase and Decrease commands, bounded state, and stopping after an excessive increase.
What it assumes
Assumes basic Scala traits and pattern matching while introducing sealed hierarchies through an actor wallet example.
What you can do after
Build typed actor protocols whose pattern matches receive compiler warnings for omitted command cases.
How it connects
Connects traits, pattern matching, actor protocols, behaviors, and typed actors.
enumalternative to · An enum is a type or language construct whose values are selected from a finite set of named alternatives, which may carry associated data.
algebraic data typeused by · An algebraic data type is a composite type whose values are formed from product structures, finite alternatives, or both through type constructors.
actor protocolpart of · An actor protocol is the set of message types and communication rules that defines how an actor can be addressed.
This explainer was generated by Manning's knowledge graph from the text of Akka in Action, Second Edition. The section links point to the parts of the book it draws on.