lua-users home
lua-l archive

Re: Modifying a table while iterating over it?

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


Cory Bloyd asked:
> What happens when you modify a table while iterating over
> it?
pairs() is implemented with next(). The reference manual
says:
# The behavior of next is undefined if, during the
# traversal, you assign any value to a non-existent field in
# the table.
Assigning values to already existing keys is fine.
-- 
Aaron

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