lua-users home
lua-l archive

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

On 9/13/06, Andreas Stenius <> wrote:
Easily fixed by checking specifically for non nil keys:

while next(t) ~= nil do
        t[next(t)] = nil

The code above calls next(t) twice per iteration instead of once.
Logically correct iteration should be:

local k= next(t)
while k ~= nil do
 t[k]= nil
 k= next(t)