in reply to Bizarre Results when Creating a Closure
I think merlyn may have said it best: "It binds to the variable $i, not the current value."
And of course, I knew that ... but somehow wasn't comprehending why my closure didn't DWIM, and just use the current value of $i each time through the loop.
So now I'll just remember the rule: "a closure binds to the variable, NOT to its value", and I should be all set.
|
|---|