4 ms·
It still can have it, see e.g. Vavr, or other functional libraries. Edit: Not sure why the downvote. This works in Java today with proper pattern matching (I
by kaba0 2y ago
It still can have it, see e.g. Vavr, or other functional libraries.
Edit: Not sure why the downvote.
This works in Java today with proper pattern matching (I left out the complete name from the permit clause, it won’t compile as is):
sealed interface <T,E> Result permits Ok, Error {
record Ok(T val) implements Result<T,E> {}
record Error(E err) implements Result<T,E> {}
}
- mrkeen 2y agoMan I hope Vavr survives. It is an oasis of rationality and I'm disheartened that https://docs.vavr.io/ https://docs.vavr.io/ appears to be down. Its Set implementation actually has union and intersection (!!!)
- Yoric 2y agoSure, and it's great that this has become possible (a while ago now). My remark was about Java ~1.0, as by now, the ship has long sailed and it's unlikely that many people will start adopting this style. (and no, I have no idea why you're being downvoted, please take my upvote)