Is a a good idea to retrofit all foreach loop to use lambda ? Was: Checked exceptions within Block<T>

Remi Forax forax at
Sat Jan 12 11:04:46 PST 2013

On 01/12/2013 05:12 AM, Michael Hixson wrote:
> An issue that came up repeatedly was that I wanted refactor code like this:
>    for (Value value : values) {
>      ...
>    }
> Into this:
>    values.forEach(value -> {
>      ...
>    });

hijacking this thread...

Blindly retrofitting all foreach loops to use lambda instead will cause 
you some perf trouble,
because the VM JIT is currently not as good as optimizing lambda calls 
as it optimizes loops.

If you have few elements (<10 000) you should not care because otherwise,
it's better to keep the good old for each loop, at least for now.


More information about the lambda-dev mailing list