delete hash[key] deprecated???

BCS ao at pathlink.com
Mon Feb 11 12:23:19 PST 2008


Reply to Leandro,

> I have this example code:
> 
> class C { ... }
> 
> C[string] hash;
> 
> auto c = new C;
> hash["x"] = c;
> // other place
> delete hash["x"];
> hash.remove("x");
> And I got: Error: delete aa[key] deprecated, use aa.remove(key)
> 
> I don't want to remove the element of the array, I want to destroy the
> object stored at key "x". Does hash.remove("x") remove the item from
> the
> hash *and* delete c? I found that a little odd. If not, do I have to
> do:
> auto c = hash["x"];
> hash.remove["x"];
> delete c;
> I find that a little odd too.
> 
> And yes, I want to explicitly delete the object because I want to
> minimize the GC activity since my program is kinda RT :)
> 

you might have luck with "delete (hash["x"]);" but I to lazy to check.




More information about the Digitalmars-d-learn mailing list