No-reuse streams

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Nov 19 07:01:15 PST 2012


On 11/19/2012 06:29 PM, Paul Sandoz wrote:
> Brian and I just pushed a changeset that:
> 
> - turns Stream/IntStream.iterator() into a terminal operation
> 
> - only one terminal operation may be performed on at most one stream
> in the pipeline, otherwise an ISE will be thrown.

Isn't iterator() the exception from this rule, being the "extension" of
the stream? I would naturally presume the *same* iterator is returned
for the given stream, so this will still be the valid code:

 Stream<T> stream = ...;
 T first = stream.iterator().next()
 // ...many, many lines of code...
 T second = stream.iterator().next()

-Aleksey.


More information about the lambda-dev mailing list