lua-users home
lua-l archive

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


Tobias Käs wrote:
> Is there an efficient way to remove all key/value pairs from a table?

Here's how I do it.  Seems to work just fine:

function zap(table)
    local next = next
    local k = next(table)
    while k do
        table[k] = nil
        k = next(table)
    end
end


Bye,
Wim