Skip to content

Instantly share code, notes, and snippets.

@weswigham
Created July 14, 2013 22:13
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 weswigham/5996325 to your computer and use it in GitHub Desktop.
Save weswigham/5996325 to your computer and use it in GitHub Desktop.
Lua scope
function SomeFunc()
local x = 3
local function InnerFunc()
x = 22
end
InnerFunc()
return x
end
--Now what does this return? This is more clear (in my opinion): 22. The x of InnerFunc goes up until it finds x in scope or hits the global namespace. In this instance, it finds x locally right above it, as we wanted it to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment