Nulls

Joe Bowbeer joe.bowbeer at gmail.com
Fri Sep 21 09:35:20 PDT 2012


> I agree, so this is where the strong force meets the heavy object.

The null penetrates the Optional?


On Fri, Sep 21, 2012 at 9:30 AM, Brian Goetz <brian.goetz at oracle.com> wrote:

> If there is this operation:
>>
>>      Optional<T> findFirst()
>>
>> then there should also be a version that takes a Predicate:
>>
>>      Optional<T> findFirst(Predicate)
>>
>
> We started there and beat a rapid U-turn.
>
> If you have findFirst(Predicate), you end up reinventing the whole stream
> protocol either with overloads of find or with other methods on Optional or
> both, because what if you want to filter and then map?  Do you do
> firstFirst(Predicate, Mapper)?  There already is filter(Predicate), so
> having a findFirst(Predicate) is unnecessary.
>
> If we have filter(Predicate) all the same arguments apply anyway.
>
>
>  But the question really boils down to whether Optional can contain null,
>> and I don't think it should.
>>
>
> I agree, so this is where the strong force meets the heavy object.  Do we
> try to keep the nulls away, or do we treat this as an illegal stream and
> blow when it gets to findFirst, or do we ignore nulls and treat them as
> "not there"?
>
>


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