2 ms·
Optionals are a bit different though, since they don't provide a way to explicitly handle errors, just wrap the `null` value if it exists and force you to be mo
by tombert 3y ago
Optionals are a bit different though, since they don't provide a way to explicitly handle errors, just wrap the `null` value if it exists and force you to be more explicit about it.
I don't know that there's a clean way to do the Either monad in Java without algebraic data types. You could certainly make a wrapper class that maybe has an optional `Left` and `Right` private variable and then make a `map` that handles the unboxing of those, but I think that might be a bit messy.
- arrakeen 3y agomy post was mostly facetious, but it is as you say: possible but probably not something anyone would want to use
- tombert 3y agoActually, I almost want to give it a try now. There's some messy try-catch Java code at work that might benefit. Don't worry, I won't deploy it until my team has seen it ;)