associative arrays: iteration is finally here
Pelle Månsson
pelle.mansson at gmail.com
Thu Oct 29 05:52:37 PDT 2009
bearophile wrote:
> Andrei Alexandrescu:
>
>> I'll make aa.remove(key) always work and return a bool that tells you
>> whether there was a mapping or not.
>
> I think that's a small design mistake. In a high level language you want things to not fail silently. You want them to fail in an explicit way because programmers often forget to read and use return values.
>
> So AAs may have two methods, "remove" and "drop" (Python sets use "remove" and "discard" for this). The "remove" can be the safer one and used by default in D programs (especially in SafeD modules, safety is in things like this too), that raises an exception when you try to remove a missing key. "drop/discard" is faster and silent, it removes the key if it's present, as you want.
>
> Bye,
> bearophile
I agree with this. I usually want exceptions.
More information about the Digitalmars-d
mailing list