Is it legal to remove a key from associative array while iterating over aa.keys if a foreach loop?

Mike Parker aldacron at gmail.com
Sun Aug 29 09:02:52 UTC 2021


On Sunday, 29 August 2021 at 08:55:44 UTC, realhet wrote:

>
>
> Is it safe, or do I have to take a snapsot of the keys range 
> like this? ->

You shouldn't remove anything when iterating over `.keys` or 
`.values`. Use `.byKey` and `.byValue` instead to get ranges that 
are independent of the aa.


More information about the Digitalmars-d-learn mailing list