8050820: Please add java.util.Optional.stream() to convert Optional<T> to Stream<T>
chris.hegarty at oracle.com
Wed Jan 21 21:34:26 UTC 2015
> On 20 Jan 2015, at 18:59, Paul Sandoz <paul.sandoz at oracle.com> wrote:
> This is one of those cases where i think adding a new method to Optional carries enough weight.
Agreed. The changes look good to me.
> It can be really awkward to use Optional with Stream.flatMap to map to a stream of present values.
> It's not at all obvious that one can do "op.map(Stream::of).orElse(Stream.empty()))" so often one sees some contorted code of there in the wild. Hopefully adding Optional.stream (and to the primitive variants) will help reduce such contortions.
> A CCC will be filed.
More information about the core-libs-dev