3 ms·
The proper analog to union types in Dart (as in Java) is enums and / or church-encoding [I think that's the term] generalized algebraic data types (GADTs). E. g
by svieira 6y ago
The proper analog to union types in Dart (as in Java) is enums and / or church-encoding [I think that's the term] generalized algebraic data types (GADTs). E. g. something like this: https://gist.github.com/jbgi/208a1733f15cdcf78eb5 https://gist.github.com/jbgi/208a1733f15cdcf78eb5
Scala 2 also had `sealed` classes that could be used in places where you needed enums parameterized by runtime values and that's been generalized in Scala 3 IIRC.
- okamiueru 6y agoI'm certainly confused now whether or not we are talking about the same thing. Without delving to much on the use of the word "union", how would you solve the use case presented in the typescript examples using enums?
- okamiueru 6y agoReading more about it, it could seem that we are talking about the same thing, except that it was so far over my head, that I didn't realise it.