Created
January 15, 2017 10:37
-
-
Save pawlos/11bec513880ce606e8b53421b2dbd647 to your computer and use it in GitHub Desktop.
Variable scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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