Page 1 of 1

For Loops in Assume-Global Functions

Posted: 16 Oct 2018, 21:41
by Ursi
In "for k, v in obj", v2 is supposed to localize k and v, which personally I think is the way to go. I was actually really surprised when I found out v1.1 didn't do this. However, "for" loops in an assume-global function still make k and v global variables. Is this the intended effect? If so, I vote to keep the behaviour consistent.

Re: For Loops in Assume-Global Functions

Posted: 16 Oct 2018, 23:35
by Ursi
Perhaps I'm mistaken and they do perform the same... I thought I tested it and saw that k and v didn't show up on the global variables list when a for loop is used in the main script body, but it looks like I was wrong...

Re: For Loops in Assume-Global Functions  Topic is solved

Posted: 17 Oct 2018, 04:05
by Helgef
In "for k, v in obj", v2 is supposed to localize k and v
The word localize might have been used in the docs at some point, I can't find it now. There shouldn't be any confusion now,
When the loop breaks or completes, these variables are restored to their former values.
It works.

You should use local appropriately, as you do for any other variables.

Cheers.