Summarising lambda features
James Shaw
js102 at zepler.net
Fri Jun 22 17:24:07 PDT 2012
On 23 June 2012 01:00, Brian Goetz <brian.goetz at oracle.com> wrote:
> Just some quick comments.
>
> As a general rule, if Iterable appears in the client code, someone
> probably made a mistake.
>
> Note also the APIs for stream operations (filter/map/forEach) are going to
> change (returning a Stream abstraction, which will be more like an Iterator
> than an Iterable), whereas the client code invocations for using them will
> not. So that's two reasons to not use Iterable in these examples.
>
Good point. In general I tend to feel that less specific types are better,
but I can see how it could be unwise to go more generic than I need to here.
>
> Method references are a bigger deal than your examples suggest. There are
> lots of mappers/predicates/sinks that are already represented as methods:
>
> strings.map(String::length).**forEach(numbers::add);
>
> (Where "strings" and "numbers" are collections.)
>
>
Your example's far better. To be honest, I was struggling to find good use
cases for the different types of method references. I'll revamp that
section when I get some time.
Thanks for the feedback!
More information about the lambda-dev
mailing list