Lambdas in for-each loops

Brian Goetz brian.goetz at oracle.com
Wed Sep 5 06:26:12 PDT 2012


> At such case I have a serious question - why for-each loop doesn't allow
> to use Iterator? Why do we need only Iterable (and arrays of course) ?
> May be it may sense to expand for-each loop itself and detach the
> problem from lambda? it looks like we something like project Coin2.0 for
> such things.

This was a hot issue during the development of the foreach loop.  In the 
end, the EG decided that allowing Iterator in foreach loop was 
potentually confusing, since as a side effect of being iterated, the 
iterator was "drained".




More information about the lambda-dev mailing list