lua-users home
lua-l archive

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

Asko Kauppi wrote:
    -- Bug hunt!
    local tbl= { 'a','b',nil,'c' }
    print( table.getn(tbl) )    -- 4 (w1) / 2 (w0)
    tbl[4]= nil
    print( table.getn(tbl) )    -- 2
    tbl[5]= { 'more..' }

This is fairly well documented behaviour (though not emphasised
enough ;)) -- table.getn() doesn't update its idea of 'n' if 'n'
already exists and you're inserting new table entries manually
(ie. without table.insert() or possibly other table.* funcs).