3 ms·
On a tangent, how do you do sum types in java? I recently wanted to use them and all I could figure out was some subclasses and `instanceof` as poor man's patte
by the_gipsy 6y ago
On a tangent, how do you do sum types in java? I recently wanted to use them and all I could figure out was some subclasses and `instanceof` as poor man's pattern matching.
- edflsafoiewq 6y agoThat's how. Sum types were largely dropped from imperative languages in favor of subclassing during the OO craze (which is why they had to be re-discovered from the functional world).
- nchi3 6y agoLook up sealed classes if you're using Java 15. There's no proper exhaustive pattern matching for them yet though, but that's coming in a future version.