![]() |
||
|
Hi all, I haven’t really followed the extensive discussion regarding locals versus globals, so please take my apology or hit me if I bring up something that was discussed already, but I need to ask this question because Lua’s behaviour seems to be quite unexpected to me here: Consider the following code: data = "" data to test with" for word in data:gmatch("(%S+)%s*") do print(word) end print(word) – Prints nil, so “word” must be local to the for-loop?! function f() x = 10; end f() print(x) – Prints 10 as I would expect Why is “word” not a global? Cheers, Christof |