https://kotlinlang.org logo
o

orangy

10/04/2015, 1:30 PM
Well, there are actually many use cases for sealed types besides plain ADT. Since direct inheritors of sealed class need not be final by themselves, it is a good way to limit hierarchies and use exhaustive
when
and otherwise constraint hierarchies. An example could be composite pattern, where sealed Node class can be either final CompositeNode or open LeafNode. So that user can’t change structure and processing rules, but can add leaf nodes at will.