2 ms·
> Except that Haskell automatically preserves the type safety, whereas you have to re-wrap the value if you're using Java. Optional has map() in Java. Optio
by Sharlin 11y ago
> Except that Haskell automatically preserves the type safety, whereas you have to re-wrap the value if you're using Java.
Optional has map() in Java.
Optional<Integer> result = Optional.empty().map(i -> i * i);
assert(!result.isPresent());
Optional<Integer> result = Optional.of(9).map(i -> i * i);
assert(result.get() == 81);