The Sealed Classes and when Expression

Learn how to use sealed classes with the when expression.

The when expression

Using when as an expression must return some value, so it must be exhaustive. In most cases, the only way to achieve this is to specify an else clause.

Get hands-on with 1200+ tech skills courses.