handful and interval

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Sep 2 08:15:58 PDT 2012


On 9/2/12 5:05 PM, Tyro[17] wrote:
> On 9/2/12 11:45 PM, Andrei Alexandrescu wrote:
>> On 9/2/12 4:22 PM, Andrei Alexandrescu wrote:
>> [snip]
>>
>> The alternative would be to simply define these as functions:
>>
>> if (a.among("struct", "class", "union")) { ... }
>> if (b.between(1, 100)) { ... }
>>
>>
>> Andrei
>
> if (a in ["struct", "class", "union"]) { ... }
> if (a in someArrayVar) { ... }
>
> works wonders for me. Why not? Somehow I cannot see the disadvantages.
> Please educate.
>
> Andrew

The first could be make to work, the second I am against on a big-oh 
complexity basis. The problem with making the first work is inconsistency.

Andrei


More information about the Digitalmars-d mailing list