3 ms·
So does Go (use the first form). Saying "loop variables are scoped outside the loop" is incorrect. All the gotchas noted stem from the fact that people are us
by amscanne 10y ago
So does Go (use the first form).
Saying "loop variables are scoped outside the loop" is incorrect.
All the gotchas noted stem from the fact that people are using _closures_ in the form of go and defer statements, which capture i by reference unless you pass it as an argument.
I think it's more an issue with closure gotchas (or the fact that go and defer statement aren't viewed that way) than with scoping.
- amscanne 10y ago(Whoops, I mean _second_ form.)