3 ms·
Hear hear. A couple more features that'd be nice: - An `public Optional<T> or(Optional<T> other)` so if optA is empty, then `optA.or(optB)` would return `optB`
by leothekim 11y ago
Hear hear. A couple more features that'd be nice:
- An `public Optional<T> or(Optional<T> other)` so if optA is empty, then `optA.or(optB)` would return `optB`
- A `toStream` method on `Optional` (I believe this is coming in Java 9) or have a `Stream.flatMap` signature that flattens `Optional`s without needing to call `Optional.toStream` (Scala does this, arguable if this is an acceptable munge of Monadic types, but it's really convenient)
- wsh91 11y agoCheck out fugue: https://bitbucket.org/atlassian/fugue https://bitbucket.org/atlassian/fugue -- a proper monadic Option and more. :) (Full disclosure: I'm an Atlassian and I know/<3 the people who write it, but I also use it a fuckton in my own code.)
- GeneTT 11y agoYea this library with Java 8 makes functional style java actually kinda nice. The addition of an Either really opens up what you can do.
- the8472 11y agoComing in java 9: http://download.java.net/jdk9/docs/api/java/util/Optional.html http://download.java.net/jdk9/docs/api/java/util/Optional.ht...