3 ms·
I think your post only takes non-null values into account, which is what OP seems to talk about. What would this code do? Optional<Int> foo = null; foo
by quchen 11y ago
I think your post only takes non-null values into account, which is what OP seems to talk about. What would this code do?
Optional<Int> foo = null;
foo.flatMap(x -> Optional.of(x));
Obeying the Monad laws would mean getting null as a result, via `m.flatMap(x -> Optional.of(x)) = m` for all m (or `m >>= pure = m` if you prefer Haskell syntax).
- deleted 11y ago[deleted]