RFR : JDK-8001642 : Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong

Brian Goetz brian.goetz at oracle.com
Fri Mar 15 06:46:48 PDT 2013


Wouldn't the minimal change NOT have a predicate, to match the existing 
form of findFirst?

   Optional<T> findFirst()
   T findFirst(T orElse)


On 3/15/2013 7:31 AM, Doug Lea wrote:
> On 03/15/13 06:26, Joe Bowbeer wrote:
>> Doug,
>>
>> I think your point that Optional and non-Optional forms of reduce are
>> already
>> provided is significant.
>>
>> I noticed that your proposed versions of findFirst and findAny have a
>> Predicate
>> argument, but the Optional forms do not:
>>
>> T findFirst(Predicate<? super T> predicate, T ifNone);
>>
>> Why is this?
>
>
> It's in the spirit of proposing a minimal change. The predicate
> form suffices for all Optional-avoiding search stuff. To reduce
> impact by another 50%, it would suffice to ONLY include the "any" form.
>    T findAny(Predicate<? super T> predicate, T ifNone);
>
> -Doug
>
>
>
>
>


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