lua-users home
lua-l archive

Re: Question about erasing tables

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


On 07/03/2017 11:49 AM, Charles Heywood wrote:
> 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
Looks like this code will not handle table with <false> key.
next() will return <false> and both <nil> and <false> considered
<false>. So it will remove table values just up to such entry.
-- Martin

AltStyle によって変換されたページ (->オリジナル) /