Revamping associative arrays
BCS
none at anon.com
Sat Oct 17 12:18:27 PDT 2009
Hello Moritz,
> On Sat, 17 Oct 2009 19:06:36 +0000, Moritz Warning wrote:
>
>> On Sat, 17 Oct 2009 18:58:08 +0000, BCS wrote:
>>
>>> what will this do?
>>>
>>> foreach(key; aa.keys)
>>> if(Test(key))
>>> aa.remove(key);
>>
>> It's undefined behavior.
>> You shouldn't try to mutate the aa while iterating. I hope that will
>> be
>> fixed.
>> It took me some time to find this out.
>
> Uh, sorry.
> You are iterating over an fresh allocated array of the keys.
> That's ok.
As it happens, your comment would be correct if .keys were, as proposed,
made to be a range that walks the AA.
More information about the Digitalmars-d
mailing list