4 ms·
To me, it's not a gotcha. As the github issue discussion notices, loops where the semantics depend on the identity of the loop variable to remain the same over
by nine_k 2y ago
To me, it's not a gotcha. As the github issue discussion notices, loops where the semantics depend on the identity of the loop variable to remain the same over the 3-clause loop iteration is exceedingly rare. I'd also say it's contrived and should not pass a code review.
Funnily, a 3-clause loop in Go (and in C) is actually a reduce(), where the loop variable's value, possibly touched by the iteration, is then directed back to the next iteration. This makes it more powerful (e.g. can traverse graphs, etc), but also more complex than it looks in the case of an integer and increment.