Safe to remove AA elements while iterating over it via .byKeyValue?
johan_forsberg_86 at hotmail.com
Sun Sep 27 13:11:21 UTC 2020
On Sunday, 27 September 2020 at 13:02:04 UTC, Per Nordlöw wrote:
> Is it safe to remove AA-elements from an `aa` I'm iterating
> over via aa.byKeyValue?
> I'm currently doing this:
> foreach (ref kv; aa.byKeyValue)
> if (pred(kv.key))
> aa.remove(kv.key); // ok?
> if (aa.length == 0)
> aa = null;
> Is there a better way?
Normally this is not advisable since you're modifying the
Same thing in C#, there it's a compiler error.
More information about the Digitalmars-d-learn