Return doesn’t belong in a while loop, nor is that the function of return. While loops automatically re-run their scopes until the condition is met (while condition do). Typically if you want to terminate a while loop, you should use break
. Return doesn’t break the loop, though it exits out of the scope. Exiting out of a while scope causes it to run again should the condition not be met.
I’m not sure what you mean by this, could you provide an example?
Whoooops, excuse me. I went and tested that in Studio, it does not do that. It does exit out of the while scope, but it does not re-run it - it terminates similarly to a break. That being said: return does not cause while loops to re-run, as I initially meant to say.
Fixing my response.
1 Like