[2.0] Remove deprecation of delete hash[key] (and change its semantics)
Jesse Phillips
jessekphillips at gmail.com
Mon Feb 11 08:26:29 PST 2008
On Mon, 11 Feb 2008 12:18:10 -0200, Leandro Lucarella wrote:
> When doing: delete hash[key] in D 1.0, there is a deprecation error
> about being an old syntax for hash.remove(key). So now, if you have an
> hash of objects, and you want to do explicit memory deallocation, you
> have to do something like this:
>
> auto tmp = hash[key];
> hash.remove(key);
> delete tmp;
>
> Which is ugly and nonsense. Maybe remove it from 1.0 could be
> contraversial, but I think there is no point in conserving this ugly
> behaviour in 2.0.
I can't test it now, but I would think that hash.remove(key) would return
the removed value. Couldn't find mention in the docs but if it is true
delete hash.remove(key);
should work.
More information about the Digitalmars-d
mailing list