4 ms·
The sealed interface, final implementation case is an interesting one to inspect. Now you can, for example, write a parser with a fixed set of tokens and write
by jayd16 4y ago
The sealed interface, final implementation case is an interesting one to inspect. Now you can, for example, write a parser with a fixed set of tokens and write switches that exhaustively handle every token. You now get compile time guarantees.
- quilombodigital 4y ago
- kaba0 4y agoYou really could do away with the arrogance.
- quilombodigital 4y agoI dont think saving a few lines for a very rare corner case is a strong reason to add a language feature
- jstimpfle 4y agoMaybe they have a point? Arrogance != Wrong in Your Opinion.
- kaba0 4y agoSure, though as I mentioned in other comment, pattern matching is basically a better Visitor pattern. Which is while not the most common pattern, is not that much of a niche either.
- jayd16 4y agoIt's just an example... And you don't seem to understand that it's about the safety of the exhaustive check not just the sugar.