lua-users home
lua-l archive

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


On 18/03/14 01:04, meino.cramer@gmx.de wrote:
I am in search of a way to create a variable in the scope of a function which is persistent i.e. does not loose it content over several calls of its funtion. best regards, mcc
Something like this?


local function give_me_a_function ()
   local foo = 0
   return function()
       foo = foo + 1
       print(foo)
   end
end

local f = give_me_a_function()
f()
f()