[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: pair()-like iterator in C++
- From: "Rici Lake" <lua@...>
- Date: Wed, 2 May 2007 17:30:11 +0100 (BST)
Leandro Pelorosso wrote:
> Indeed, but, don't you know what kind of undefined
> behavior can i get?. (maybe something like iterate
> elements that i already visit, or something like that)
Undefined is undefined. You could get repeat elements,
you could miss elements, you could get an error. About
all you can say is that it won't crash.
Your best bet is to add the new elements to another
table and then merge them afterwards:
do
local newstuff = {}
for k, v in pairs(tab) do
-- whatever
if some_condition then
newstuff[newkey] = newval
end
end
for k, v in pairs(newstuff) do
tab[k] = v
end
end