3 ms·
Probably worth pointing out that C# used to have Go's behavior and they changed it (a rare breaking language change) specifically because it was such a notoriou
by munificent 3y ago
Probably worth pointing out that C# used to have Go's behavior and they changed it (a rare breaking language change) specifically because it was such a notorious pitfall.
I think Go is doing the right thing here. I'm somewhat surprised they didn't always do this. (Dart has created a new loop variable for each iteration all the way back since before 1.0.)
- masklinn 3y agoSimilarly in javascript, “let” and “const” we’re added specifically with block and per-iteration scoping, because the ever increasing popularity of callbacks for async was making the function-scoped var more infuriating every day.