easier work with collections: default Stream.toList?
Paul Benedict
pbenedict at apache.org
Sun Sep 29 09:31:17 PDT 2013
I think, at one time, someone recommended toArray() and Brain said this
would obviously fail with infinite streams. Wouldn't toList() bring the
same consequences?
On Sun, Sep 29, 2013 at 10:53 AM, Zhong Yu <zhong.j.yu at gmail.com> wrote:
> +1
>
> >From my own experience, I'd definitely love to see a Stream.toList()
> method.
>
> Zhong Yu
>
>
> On Sat, Sep 28, 2013 at 4:21 AM, <stephane.demurget at free.fr> wrote:
> > hi guys,
> >
> > Brian, you mentioned back in May the possibility that the EG might
> consider adding a small number of convenience methods/shortcuts for
> collecting elements:
> >
> >
> http://mail.openjdk.java.net/pipermail/lambda-dev/2013-May/009798.html
> > (can't reply as I was not subscribed at the time, sorry)
> >
> > I see the API freeze deadline is approaching, and I grasp the problem of
> opening more API demand or the intent to guide users to using Collectors
> entirely instead, but is there any hope?
> >
> > We have ~15 years of APIs all over the world accepting Collections and
> Maps, and I really think having those two:
> >
> > * .toList() -> .collect(Collections.toList())
> > * .groupBy(classifier) -> .collect(Collections.groupingBy(classifier))
> >
> > would be a huge asset to use existing librairies smoothly, increasing
> readability and helping newcomers for the simplest and most common cases.
> >
> > I understand static imports can increase readability a bit, and IDE
> support will certainly help in that area, but until now they were no real
> API "requiring" this way of writing (and if you're not, it's really
> verbose). I'm confident having these shortcuts with javadoc to gently point
> users to collectors would be really more helpful and expected.
> >
> > I personally do not think .toSet() is worth it though.
> >
> > --Stéphane
> >
>
>
--
Cheers,
Paul
More information about the lambda-dev
mailing list