lua-users home
lua-l archive

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


> When you call newCounter(), you'll create a new instance of j (the
> definition is within newCounter), but reuse the existing i (its definition
> is outside newCounter).

For explanatory purposes, we may think that each time the program
"executes" 'local x' it creates a new 'x' variable. Your code executes
'local i' only once, so there is only one 'i'. 

-- Roberto