Created
December 22, 2014 02:59
-
-
Save DamonHao/cfbf4c47e4077b0adb95 to your computer and use it in GitHub Desktop.
Local and global variable
This file contains hidden or 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
| function test() | |
| x = 1 -- default is global | |
| local y = 2 | |
| end | |
| local function main() | |
| test() | |
| print(x, y) | |
| end | |
| main() | |
| -- output 1 nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment