3 ms·
Closures capture all in-scope variables by reference in most languages. Same situation in Python for example: https://stackoverflow.com/questions/54288926/pyth
by shawnz 6y ago
Closures capture all in-scope variables by reference in most languages.
Same situation in Python for example: https://stackoverflow.com/questions/54288926/python-loops-and-closures https://stackoverflow.com/questions/54288926/python-loops-an...
- closeparen 6y agoYou can get bitten by a similar problem without closures if you stick a loop variable in an array. The loop variable is one address with contents mutating each iteration.
- masklinn 6y ago> You can get bitten by a similar problem without closures if you stick a loop variable in an array. Surely only if you store it indirectly, otherwise it'll be copied into the array.