I need to take some time to check if the documentation would not benefit from a gigantic red box pointing out this for
loop scope property. It is not the first question this comes up. And it is also important if you are dealing with closures inside a for
loop too. There is a section of the manual that points out this scope property and also that you may reuse an existing variable as iterator with the keyword outer
, but maybe it is not very noticeable.