is using local for same variable multiple times safe?
Posted: Fri Mar 31, 2023 9:52 am
I just noticed that having used copy-paste I have done something unnecessary, using "local" multiple times for same variable, and now I wonder if I need to fix this possibly, short imaginary example of the thing:
Just suddenly realised I have whole bunch of lines like this, where Local is not really necessary, could have just used it the first time and left it out from the rest.
Seems program is working just fine at least currently, but is there some potential problem this could cause, and therefore I should remove those unnecessary "local"s, or is it safe to leave them as they are?
Code: Select all
local newitem = {x=1, y=2}
insertitem(mytable, newitem)
local newitem = {x=3, y=4}
insertitem(mytable, newitem)
local newitem = {x=5, y=6}
insertitem(mytable, newitem)
Seems program is working just fine at least currently, but is there some potential problem this could cause, and therefore I should remove those unnecessary "local"s, or is it safe to leave them as they are?