delete hash[key] deprecated???

Leandro Lucarella llucax at gmail.com
Mon Feb 11 05:07:22 PST 2008


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 :)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Peperino nos enseña que debemos ofrendirnos con ofrendas de vino si
queremos obtener la recompensa de la parte del medio del vacío.
	-- Peperino Pómoro


More information about the Digitalmars-d-learn mailing list