I have the following function
function test() local function test2() print(a) end local a = 1 test2() end test()
Prints nil
Next script
local a = 1 function test() local function test2() print(a) end test2() end test()
prints 1.
I do not understand this. I thought that declaring a local variable makes it valid throughout the block. Since the variable 'a' is declared in the scope of test () - function, and the function test2 () is declared in the same scope, why does test2 () not have access to the local variable test ()?
source share