[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: NIL in arith. and string op.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 06 Jan 2004 09:30:50 -0200
> Perhaps, better is initialize...
Or use metatables:
-- Metatable
local a = {}
setmetatable(a, {__index = function () return 0 end})
for i = 1, 5000 do
for j = 1, 1000 do
a[i] = a[i] + j
end
end
It gives the same performance that `Init' and it is more flexible,
because you do not need to know beforehand which indices will be used.
-- Roberto