Answered by
8 years ago Edited 8 years ago
local
sets the variable so that it's only available in the current scope.
in these examples, world is just the name of the function, it could be anything
This happens because b is now only available inside of the function (The scope) where it was created.
The following works because the value of b is created outside of the function world()
, so it can be accesed outside of it.
This works too because b isn't local.
Another thing to note is that local
variables are indexed a bit faster (barely noticable though)