Loose ends: Optional
Paul Sandoz
paul.sandoz at oracle.com
Mon Jun 10 02:43:33 PDT 2013
On Jun 7, 2013, at 9:47 PM, Brian Goetz <brian.goetz at Oracle.COM> wrote:
> So, here are the decisions I see from this list:
>
> - Given map/flatMap, must we / do we also need ofNullable and orNull?
> - If the mapper returns null, should we continue to silently convert to empty optional or throw NPE?
The former behaviour is may be confusing since it is inconsistent with stream methods that return Optional, and there is a stronger connection to Stream than to Map.
> - Does renaming ifPresent to forEach help or hurt?
I think it conceptually helps.
> What about implementing Iterable?
>
It seems nice to have. I am wondering if there are possible consequences if we decide to move the stream methods from Collection to Iterable.
FWIW the documentation on Scala's Option notes:
"Many of the methods in here are duplicative with those in the Traversable hierarchy, but they are duplicated for a reason: the implicit conversion tends to leave one with an Iterable in situations where one could have retained an Option."
Paul.
More information about the lambda-libs-spec-observers
mailing list