My Kingdom For ...
Michiel Helvensteijn
nomail at please.com
Thu Feb 21 09:06:40 PST 2008
Janice Caron wrote:
> On 21/02/2008, Michiel Helvensteijn <nomail at please.com> wrote:
>
>> It's silly that 'in' does not return a bool.
>
> Huh? But I don't want it to return a bool. If it retured a bool, I
> wouldn't be able to do
>
> auto p = key in aa;
> if (p is null)
> {
> /* do something */
> }
> else
> {
> return *p;
> }
>
> Without that ability, you'd have to do a double-lookup!
In those cases you use that library function I mentioned. It would do the
exact thing 'in' does now.
When I read: key in aa, I understand: key is member of aa. Like the operator
in set theory (looks like an epsilon). Apparently I'm not alone in this
if !in has been requested so often.
--
Michiel
More information about the Digitalmars-d
mailing list