Hacker News new | past | comments | ask | show | jobs | submit login

I do in general like all the nice improvements they've been making to Java over time (as someone who loved Scala back in 2015 or so). But this is silly; they should introduce a sealed `Try` type like Scala has (or, well, just steal the version from the Java "vavr" library), with `Success`/`Failure` record implementations, and then you can destructure in the switch statement. So something like https://java.godbolt.org/z/dh5ebPfeq

The benefit there is that it doesn't require any changes to language or syntax. Hell, you can even use vavr's `Try` and achieve the same effect, though I guess you can't destructure in the same way as it doesn't use record.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: