Removing items from an Array
Jonathan M Davis
jmdavisProg at gmx.com
Fri Feb 17 02:11:35 PST 2012
On Friday, February 17, 2012 11:00:36 Mars wrote:
> Hello everybody.
> Once again I have a little question, this time about removing
> items from an assoc array in a foreach.
>
> Why does the following code:
> http://pastebin.com/65P9WDNS
> Result in this output:
> http://pastebin.com/4FzEE1zi
>
> It seems rather strange to me. I'd expect the foreach_reverse to
> go over the array from the end to the beginning, and when I
> remove stuff from it, it shouldn't be a problem. But apparently
> it is.
I don't believe that removing elements from an AA while iterating over it is
safe.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list