easier work with collections: default Stream.toList?
Ivan Savchenko
ivan.a.savchenko at gmail.com
Sun Sep 29 18:18:13 PDT 2013
+1, I personally was really surprised when didn't find those shortcuts
in current Stream API
--
Kind regards,
Ivan
On Sat, Sep 28, 2013 at 4:21 AM, <stephane.demurget at free.fr
<http://mail.openjdk.java.net/mailman/listinfo/lambda-dev>> 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*>
More information about the lambda-dev
mailing list