I have the following function
function test()
local function test2()
print(a)
end
local a = 1
test2()
end
test()
This prints out nil
The following script
local a = 1
function test()
local function test2()
print(a)
end
test2()
end
test()
prints out 1.
I do not understand this. I thought declaring a local variable makes it valid in its entire block. Since the variable 'a' is declared in the test()-function scope, and the test2()-function is declared in the same scope, why does not test2() have access to test() local variable?