in reply to RE: RE (tilly) 3 (closures): for loops
in thread for loops, closures
The foreach loop iterates over a normal list value and sets the variable VAR to be each element of the list in turn.It is directly aliased. If you modify the element that you are iterating over, you modify the elements of the array, if you modify the elements of the array you modify the element that you are iterating over, and if you create a closure that temporary aliasing becomes longer-lived.
|
|---|