I can\'t explain an issue I\'ve run across. Basically I get a different answer if I use lambda syntax in a foreach loop than if I use it in a for loop. In the code below I r
This is the classic issue of a captured closure with a scope that isn't what you expect. In the foreach, the action has outer scope, so the execution captures the last value of the loop. In the for case, you create the action in inner scope, so the closure is over the local value at each iteration.