How to change the loop variable in a for loop?

hmm…
this works:

var i = 0
while(i<10):
  if(foo):
    bar
    i -= 1
  i += 1

but is less readable, var i is now outside loop scope, continues and the iteration have to be handled.
If anyone figures out a better solution, please add it.

1 Like