[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Changing tables during traversal: clearing and re-adding a field
- From: Dirk Feytons <dirk.feytons@...>
- Date: Wed, 29 Jun 2011 18:15:02 +0200
The reference manual clearly describes what can and cannot be done to
a table during traversal: modifying and clearing an existing field is
OK, assigning to a non-existing field is bad.
But what happens if I clear an existing field and then assign to it
again during one iteration? In pseudocode:
for k,v in pairs(t) do
t[k] = nil
if (<some condition>) then
t[k] = <some other value>
Is this allowed? We've seen some intermittent errors in our code that
I suspect are coming from a pattern like described above.