4 ms·
You might already know of this since you mentioned pattern matching, but there is the `sealed` class modifier which allows for exhaustive matching on class subt
by steve_adams_86 3y ago
You might already know of this since you mentioned pattern matching, but there is the `sealed` class modifier which allows for exhaustive matching on class subtypes. It's very limited: https://dart.dev/language/class-modifiers#sealed https://dart.dev/language/class-modifiers#sealed
I recall there being a reason unions aren't generally implemented, though I'm not sure where I read it. It was to do with union types being unnecessarily complex for the compiler and the code they tend to produce, at no real benefit to the programmer or the resulting program. Go's lack of unions is essentially based around the same reasoning.
It looks like it's an open discussion for Dart, but I can't see any explicit plans for an implementation.
- Alifatisk 3y agoThe sealed class with the switch case pretty much solves my issue cleanly, thanks!
- steve_adams_86 3y agoNice, I know hardly anything about Dart so I’m glad what little I know was of use.