Skip to content

Instantly share code, notes, and snippets.

@pawlos
Created January 15, 2017 10:37
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 pawlos/11bec513880ce606e8b53421b2dbd647 to your computer and use it in GitHub Desktop.
Save pawlos/11bec513880ce606e8b53421b2dbd647 to your computer and use it in GitHub Desktop.
Variable scope
x = 10 -- global variable
do -- new block
local x = x -- new 'x', with value 10
print(x) --> 10
x = x+1
do -- another block
local x = x+1 -- another 'x'
print(x) --> 12
end
print(x) --> 11
end
print(x) --> 10 (the global one)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment