[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Changing tables during traversal: clearing and re-adding a field
- From: Philippe Lhoste <PhiLho@...>
- Date: Thu, 30 Jun 2011 13:39:05 +0200
On 29/06/2011 18:15, Dirk Feytons wrote:
for k,v in pairs(t) do
t[k] = nil
if (<some condition>) then
t[k] =<some other value>
end
end
Unless I am missing something (maybe the real code is much more complex), you can rewrite
it as:
for k, v in pairs(t) do
if (<some condition>) then
t[k] = <some other value>
else
t[k] = nil
end
end
no?
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --