Hey guys, today a simple question.
What is the point of making a "local" variable, when you can't use a variable in other scripts even if it global?
I know it might sound as a noob question, but I will be happy for any explanation, or an answer.
Thanks in advance!
A "local" Variable, is restricted to the enclosing function, If you wanted to not get confused with all your variables its quite useful.
01 | Jim = "Jim" |
02 |
03 | function example() |
04 | local Bob = "Bob" |
05 | print (Bob) -- Prints "Bob" |
06 | print (Jim) -- Prints "Jim" |
07 | end |
08 | example() |
09 | print (Jim) -- Prints "Jim" |
10 | print (Bob) -- Errors |