[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: For loops and closures
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 30 Apr 2003 09:55:24 -0300
> You should be able to get what you want by writing:
>
> local function makeBinding(v)
> return function(x) return g(v,x) end
> end
>
> for k,v in pairs(t) do
> g_bindings[k] = makeBinding(v)
> end
A simpler way is
for k,v in pairs(t) do
local v = v
g_bindings[k] = function(x) return g(v,x) end
end
-- Roberto