Re: Best way to iterate and remove
Posted: Thu Dec 19, 2013 11:47 am
Well, pairs uses next internally, and the docs have this to say about next:
Note that pairs is approximated by:The behavior of next is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may clear existing fields.
Code: Select all
function pairs(t)
return next, t, nil
end