Additional method on Stream

Paul Sandoz paul.sandoz at oracle.com
Tue Apr 28 07:16:29 UTC 2015


On Apr 27, 2015, at 10:34 PM, Kasper Nielsen <kasperni at gmail.com> wrote:
> The other default function I would like to see is stream.toList() (I can
> live with collectToList) which is short for s.collect(Collectors.toList()).
> 50 % of my terminal functions are s.collect(Collectors.toList()).

Can you live with a static import and:

  s.collect(toList())

? which is rather close to "collectToList".

When designing j.u,s.Stream we made a conscious decision to not bind it to j.u collection types. A Stream could be integrated with other forms of collections (e.g. GS Collections).

Paul.

> And I took a look at libraries that uses the Stream interface GitHub and it
> is roughly the same usage.
> 
> - Kasper




More information about the core-libs-dev mailing list