Skip to content

Instantly share code, notes, and snippets.

@MihailJP
Created September 2, 2012 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MihailJP/3599125 to your computer and use it in GitHub Desktop.
Save MihailJP/3599125 to your computer and use it in GitHub Desktop.
Lua scope test
v = "global"
do
print(v) -- "global"
local v = "local"
print(v) -- "local", of course
v = nil
print(v) -- nil, not "global"
collectgarbage("collect")
print(v) -- still nil
print (_G.v) -- of course "global"
end
print(v) -- "global"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment