Can remove AA elements during foreach?

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Sat Feb 16 15:59:59 PST 2013


Is this both legal and safe?:

    foreach(key; assocArray)
    if(key != "foobar")
        assocArray.remove("foobar");

If not, then what about this?:

    foreach(key; assocArray.byKey())
    if(key != "foobar")
        assocArray.remove("foobar");



More information about the Digitalmars-d-learn mailing list