3 ms·
Sealed classes still won't let you have e.g. String|Integer, though I'll grant you that java is certainly mainstream.
by thfuran 2y ago
Sealed classes still won't let you have e.g. String|Integer, though I'll grant you that java is certainly mainstream.
- kagakuninja 2y agoScala 3 has had union types for 4 years now. Scala can be used to do Haskell style pure FP, but with much better tooling. And it has the power of the JVM, you can fall back to Java libraries if you want.
- SkiFire13 2y agoYou don't really need `String|Integer`, for most usecases an isomorphic type that you can exhaustively pattern match on is more than enough, and sealed classes (along with the support in `switch` expressions) does exactly that.