Stream.peek() javadoc

Paul Sandoz paul.sandoz at oracle.com
Thu Aug 22 05:37:50 PDT 2013


On Aug 22, 2013, at 12:00 PM, Richard Warburton <richard.warburton at gmail.com> wrote:

> Hi,
> 
> The current code snippet in stream.peek() seems to be a bit out of date.
> Its currently:
> 
>     list.stream()
>         .filter(filteringFunction)
>         .peek(e -> {System.out.println("Filtered value: " + e); });
>         .map(mappingFunction)
>         .peek(e -> {System.out.println("Mapped value: " + e); });
>         .collect(Collectors.intoList());
> 
> I suggest changing this to:
> 
>     list.stream()
>         .filter(filteringFunction)
>         .peek(e -> System.out.println("Filtered value: " + e));
>         .map(mappingFunction)
>         .peek(e -> System.out.println("Mapped value: " + e));
>         .collect(Collectors.toList());
> 

Thanks! updated:

http://hg.openjdk.java.net/lambda/lambda/jdk/rev/7bb72727c1ad

I did a very quick search for other "-> {" in docs and could not find further expressions that could be simplified.

Paul.


More information about the lambda-dev mailing list