Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Scope-modifiers/Lua/scope-modifiers.lua
Normal file
16
Task/Scope-modifiers/Lua/scope-modifiers.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
foo = "global" -- global scope
|
||||
print(foo)
|
||||
local foo = "local module" -- local to the current block (which is the module)
|
||||
print(foo) -- local obscures the global
|
||||
print(_G.foo) -- but global still exists
|
||||
do -- create a new block
|
||||
print(foo) -- outer module-level scope still visible
|
||||
local foo = "local block" -- local to the current block (which is this "do")
|
||||
print(foo) -- obscures outer module-level local
|
||||
for foo = 1,2 do -- create another more-inner scope
|
||||
print("local for "..foo) -- obscures prior block-level local
|
||||
end -- and close the scope
|
||||
print(foo) -- prior block-level local still exists
|
||||
end -- close the block (and thus its scope)
|
||||
print(foo) -- module-level local still exists
|
||||
print(_G.foo) -- global still exists
|
||||
Loading…
Add table
Add a link
Reference in a new issue