peek().iterator().hasNext() pre-consumes elements?

Remi Forax forax at univ-mlv.fr
Tue Feb 12 09:56:01 PST 2013


On 02/12/2013 06:53 PM, Dmitry Bessonov wrote:
> Hello,
>
> The following line prints out the first element, "1"
>
>     Arrays.asList(1, 2,
> 3).stream().peek(System.err::println).iterator().hasNext()
>
> Is it really an expected behavior?
>
> -Dmitry
>
>
>
no, it's not.

Rémi



More information about the lambda-dev mailing list