Skip to content

Instantly share code, notes, and snippets.

@videlais
Created April 13, 2018 03:16
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 videlais/c520611c66e8ab17af298898975c055a to your computer and use it in GitHub Desktop.
Save videlais/c520611c66e8ab17af298898975c055a to your computer and use it in GitHub Desktop.
scopeproblem.lua
testValue = 1
function newFunction()
-- This will work
print("The value is " .. testValue)
local newValue = 2;
end
newFunction()
-- This will NOT work.
-- newValue is only defined within the scope of newFunction()
print("What is newValue?" .. newValue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment