lua-users home
lua-l archive

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


> In Chapter 2, Roberto mentions that "If you want to erase all elements from a table, a simple traversal is the correct way to do it:
> 
> for k in pairs(t) do
>     t[k] = nil
> end
> 
> Roberto then goes on to mention an improvement to this:
> 
> while true do
>     local k = next(t)
>     if not k then break end
>     t[k] = nil
> end

Did you turn the page? :-)

-- Roberto