4 ms·
The point of sealed classes is that you have a known number of possible representations. So you can have `when` blocks that exhaustively check all possibilities
by balefrost 5y ago
The point of sealed classes is that you have a known number of possible representations. So you can have `when` blocks that exhaustively check all possibilities. Having an open class hierarchy would not work for that purpose.
- __jem 5y agothis technique works with sealed classes, i’ve done it before. it throws a runtime exception if it can’t identify the discriminant.