lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Nick Gammon wrote:
Yes I see what is happening, but the surprising thing is that local variables behave so much differently to other types of variables.

Jerome's excellent post explains this. Using local with assignment is syntactic sugar for a local declaration followed by an assignment. Separating the local declaration from the assignment allows you to "see" what is really happening:

b = 3  -- modifies _G.b
b = 4  -- modifies _G.b
local a
a = 3  -- modifies local a
a = 4  -- modifies local a

					-Mark