Re: Snippet for dumping tables when testing
Posted: Wed Sep 21, 2011 9:11 pm
A good way to approach this is to look at where the variable is used, and look upwards, and up indentation levels.
You stop when you see:
Although there's more to it, what I just described is the gist of it.
You stop when you see:
- local var: it is a local variable
- for var = 1, 10 do or for var in somegenerator() do: it is a local variable
- function bluh(var, bluh): it is a local variable
- You are at the start of the file: it is a global variable
Code: Select all
function a (shazam)
function b()
print(shazam) -- a local variable, to be exact the argument to a
end
end