[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.2 new function reference inside a loop
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 15 Sep 2014 11:20:38 -0300
> for i=0,2 do
> local i_store = i
> local a = function() end;
> print(a);
> end
You need to use i inside the function to create different closures:
for i=0,2 do
local a = function() local _=i end
print(a)
end
But why do you need different functions that do the same thing?
(or should I say same nothing? :-)