delete hash[key] deprecated???
Simen Kjaeraas
simen.kjaras at gmail.com
Fri Jul 18 08:23:30 PDT 2008
Regan Heath <regan at netmail.co.nz> wrote:
> JAnderson wrote:
>> Max Samukha wrote:
>>> On Wed, 16 Jul 2008 01:23:30 +0400, "Koroskin Denis"
>>> <2korden+dmd at gmail.com> wrote:
>>>
>>>> But you still have to remove a dead pointer from a collection:
>>>>
>>>> delete *("x" in hash);
>>>> hash.remove("x");
>>>
>>> If 'remove' was modified to return the removed value, more compact
>>> syntax would be possible:
>>>
>>> delete hash.remove("x");
>>>
>>> Also, there would be no need to search for the value twice and
>>> introduce a temporary when the removed value is needed for further
>>> processing:
>>>
>>> // do something with the value, for example, pass it to a function
>>> foo(hash.remove("x"));
>>>
>>> instead of:
>>> auto v = hash["x"];
>>> hash.remove("x");
>>> foo(v);
>> I think this is a good idea.
>
> Seconded!
>
> Regan Heath
Thirded!
-- Simen
More information about the Digitalmars-d-learn
mailing list