flatMap signature

Brian Goetz brian.goetz at oracle.com
Tue Apr 2 06:06:42 PDT 2013


> -----------------------------------------------------------------------------------------------------------
> T reduce(T identity, BinaryOperator<T> accumulator);
> and
>   Optional<T> reduce(BinaryOperator<T> accumulator);
>
> Can't be fixed because they used 'BinaryOperator', But if 'BiFunction' is
> used then we have more flexibility

Not sure if "fixed" is the right word here :)

In any case, you've correctly identified that the argument to 
BinaryOperator is invariant because it is both an input and output 
parameter.

> ------------------------------------------------------------------------------------------------------------
> <R> R collect(Supplier<R> resultFactory,
>                        BiConsumer<? super R, ? super T> accumulator,
>                        BiConsumer<? super R, ? super R> combiner)
>
> Instead of:
>
>      <R> R collect(Supplier<R> resultFactory,
>                    BiConsumer<R, ? super T> accumulator,
>                    BiConsumer<R, R> combiner);

Looks right.



More information about the lambda-dev mailing list