delete hash[key] deprecated???
    Stewart Gordon 
    smjg_1998 at yahoo.com
       
    Mon Jul 14 17:14:37 PDT 2008
    
    
  
"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message 
news:fopjrt$1b2c$1 at digitalmars.com...
<snip>
>> If not, do I have to do:
>> auto c = hash["x"];
>> hash.remove["x"];
>> delete c;
>
> Yeah, you do.
No I don't.
    delete * cast(Object*) &hash["x"];
Test code:
----------
import std.stdio;
class Test {
    ~this() { writefln("Object destroyed"); }
}
void main() {
    Test[int] aa;
    aa[42] = new Test;
    delete * cast(Object*) &aa[42];
    writefln(42 in aa);
}
----------
The last statement is as much to show that it is actually deleted there and 
then as to show that it suppresses removal of the AA key.
Stewart.
-- 
My e-mail address is valid but not my primary mailbox.  Please keep replies 
on the 'group where everybody may benefit. 
    
    
More information about the Digitalmars-d-learn
mailing list