Like enum
, a sealed class works well with when()
. We know all possible
objects and subclasses of the sealed class when we compile the code, so we know
whether the when
is "exhaustive", even without an else
branch.
You can learn more about this in:
Tags: