Stream.limit() - puzzler/bug/feature
Brian Goetz
brian.goetz at oracle.com
Thu Nov 15 07:17:42 PST 2012
Yes, don't do that :)
On 11/15/2012 3:32 AM, Dmitry Bessonov wrote:
> Hello,
>
> While playing with method Sream.limit(int) using a mini-code like
>
> final Stream<Integer> s = Arrays.asStream(1, 2, 3, 4, 5);
> final Stream<Integer> to3 = s.limit(3);
> final Stream<Integer> to4 = s.limit(4);
>
> have to admit that there's no unambiguous answer
> to the question of contents of streams "to3" and "to4".
> It depends on which of the streams is consumed first.
>
> Might situations (and mis-usage?) like this above
> be a trap for novice users
> that should be well described?
>
> Dmitry
>
>
More information about the lambda-dev
mailing list