4 ms·
> And it's also a behavior that is never useful. False. There are cases where it is useful to have the loop variable available directly. For example, you can a
by mik1998 3y ago
> And it's also a behavior that is never useful.
False. There are cases where it is useful to have the loop variable available directly. For example, you can add one to the loop variable to skip an iteration, which would not work with an iteration-local loop variable.
- simiones 3y agoIn a for-in-range loop, the variables are read-only inside the loop body, so there is no way to skip this. I do agree that there are reasons to modify the iteration variable in a C-style for loop, so I am surprised that those loops are being modified as well. C#, which went through a similar change, did NOT apply such a change for those for loops.