Nulls

Tim Peierls tim at peierls.net
Sun Sep 23 07:10:00 PDT 2012


On Sun, Sep 23, 2012 at 9:58 AM, Doug Lea <dl at cs.oswego.edu> wrote:

> So unobvious that I still don't see it. As long as you aren't treating
>> null as
>> an acceptable value in Streams or as the contents of an Optional, why do
>> you
>> need to re-check?
>>
>
> Suppose there are two elements that match predicate, one null, one
> nonnull. And suppose the findAny implementation finds the null one
> first and so reports an absent Optional.


Brian said:

I would rather not punish everyone because some idiot puts nulls in a
> collection and that same idiot filters/maps it with lambdas that can't deal
> with nulls.


and I'm solidly behind that. (Although for marketing purposes, we should
find a better word than "idiot".) What I'm taking away from Doug's message
is that there are *no* lambdas that can deal with nulls.

So I reject the premise ("Suppose there are two elements that match
predicate, one null, one nonnull."). A predicate can't match null
meaningfully, so let's not bend over backwards -- I'm using that expression
a lot, I know -- to try to find complete consistency when nulls are
involved.

--tim


More information about the lambda-libs-spec-observers mailing list