lua-users home
lua-l archive

Re: Modifying a table during an ipairs loop

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


Hello Dirk,
Thursday, September 3, 2015, 1:30:45 PM, you wrote:
> for k,v in ipairs(t) do if type(v)=='table' then
> if v[1] then
> table.insert(t,k,v[1]); table.remove(v,1)
> else table.remove(t,k)
> end
> end
> Hint: it almost does what it should, but there is a bug.
It skips an item in <t> after the previous item was a table and was emptied out.
Right? Because it should.
-- 
Best regards,
 John mailto:0x42484156@gmail.com

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