lua-users home
lua-l archive

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

> Isn't the "obvious" way to empty a table to...

Yes, but its performance is awful on large tables. It is basically 
quadratic in table size.

Actually, I don't think your code handles a table with the key false.


function noxt(table) return next(table, nil) end
for key in noxt, table do table[key] = nil end

But that doesn't get around the performance problem.