delete hash[key] deprecated???

Max Samukha samukha at voliacable.com.removethis
Sat Jul 19 00:35:01 PDT 2008


On Fri, 18 Jul 2008 22:27:16 +0100, "Stewart Gordon"
<smjg_1998 at yahoo.com> wrote:

>"Max Samukha" <samukha at voliacable.com.removethis> wrote in message 
>news:9d2r74tuopl0dt05sgnkagss4gu4824k9m at 4ax.com...
><snip>
>> If 'remove' was modified to return the removed value, more compact
>> syntax would be possible:
>>
>> delete hash.remove("x");
><snip>
>
>And what would remove do if the key is already not in the AA?  Return 
>ValueType.init?  Throw an exception?
>
>Stewart.

Three options:

1. Throw an assert exception if the program was built with a debug
switch
2. Always throw an exception
3. Make 'remove' return a pointer to the value
4. Continue silently 

I prefer the first option. Option 4 (current semantics)  is the least
acceptible, in my opinion.  


More information about the Digitalmars-d-learn mailing list