More uses of operator "in"

Baz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 28 10:50:29 PDT 2014


On Tuesday, 28 October 2014 at 16:32:13 UTC, Marc Schütz wrote:
> On Tuesday, 28 October 2014 at 15:11:01 UTC, Baz wrote:
>> On Tuesday, 28 October 2014 at 13:50:24 UTC, Nordlöw wrote:
>>> Has there been any proposals/plans to make operator "in" work 
>>> for elements in ranges such as
>>>
>>>   assert('x' in ['x']);
>>>
>>> I'm missing that Python feature when I work in D.
>>
>> There is also something similar in Pascal, at the language 
>> level. Very handy when working with characters or enums.
>
> AFAIR it's limited to sets in Pascal, where its complexity is 
> O(1).

If "in" is used as a syntactic sugar, e.g to call 
"std.algorithm.canFind" in a custom type, then why would the bigO 
be a concern ? To be clear, I was just trying to suggest that it 
can be done by writting from scratch some helpers structs.


More information about the Digitalmars-d-learn mailing list