easier work with collections: default Stream.toList?
Paul Sandoz
paul.sandoz at oracle.com
Wed Oct 2 09:12:20 PDT 2013
On Oct 2, 2013, at 6:02 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:
> By the same reasoning, List should not be used in any public API ever:)
>
Ermm... only if you take that reasoning to an unreasonable level :-)
Paul.
> The proposed toList() method is obviously a backward looking API to
> help Stream to interact with legacy code/mindset. It is "not pure",
> but it is very useful.
>
> Another use case to consider: in a new API method, I could return a
> Stream or a List. I prefer Stream, but I suspect that a lot of users
> would rather see a List instead, which makes me really hesitant to
> return a Stream. If Stream had a toList() method, and assume
> list.stream().toList() is very efficient, then there's no problem to
> return a Stream here.
>
> Zhong Yu
More information about the lambda-dev
mailing list