lua-users home
lua-l archive

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


Cory Bloyd wrote:
for key, value in pairs(someTable) do
      if someArbitraryCondition() then
            someTable[newKey()] = newValue()
      end
end

If you are not short in memory, you can iterate on someTable and copy existing keys and creating new keys in a new table. Then replace someTable with newTable and you are safe.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --