4 ms·
I'm not aware of any current Java project on Sum types. There is multi-catch for exceptions but no immediate plans I know to use elsewhere.
by karmakaze 6y ago
I'm not aware of any current Java project on Sum types. There is multi-catch for exceptions but no immediate plans I know to use elsewhere.
- apta 6y agoA form of pattern matching and switch expression has already made it to the language as of JDK 14. Those are paving the way for full blown pattern matching and sealed types: https://cr.openjdk.java.net/~briangoetz/amber/datum.html https://cr.openjdk.java.net/~briangoetz/amber/datum.html https://openjdk.java.net/jeps/360 https://openjdk.java.net/jeps/360
- richardwhiuk 6y agoJava aren't fixing nulls, IMHO. They are making it worse.
- apta 6y agoHow are they making it worse? In any case, there already exist solutions in place: https://checkerframework.org/manual/#example-use https://checkerframework.org/manual/#example-use https://github.com/uber/NullAway https://github.com/uber/NullAway
- richardwhiuk 6y agoThe code ends up looking like: Optional<Integer> foo; //.... if (foo != null) { foo.and_then(new Consumer () { function accept(Integer foo) { } }); }
- karmakaze 6y agoI would never assign null to an Optional nor use a library that returned one. To ensure assignment before use make it final.