[swift-evolution] Proposal: Python's "in" and "not in" syntactic sugar

Jeremy Pereira jeremy.j.pereira at googlemail.com
Thu Dec 17 09:48:02 CST 2015


> On 17 Dec 2015, at 15:59, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Dec 17, 2015, at 9:51 AM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> 
>>> if “hello” in [“hello, there”] { … }
>>> 
>>> if “hello” not in [“hello, there”] { … }
>> 
>> Swift is extremely sparing with keywords in operator position; the only ones I can think of off the top of my head are `is` and `as`, and even those aren’t actually operators. You’re proposing to introduce one as syntactic sugar for [array].contains(elem), and introduce an even more bizarre two-word operator for ![array].contains(elem). I don’t think that’s gonna fly.
> 
> Most programmers would probably love using them though.


If that’s the case, I’d be in the minority. 

I’d rather use [“hello", “there”].contains(“hello”). That might just be my background though which is heavily object oriented.

> 
>> 
>> -- 
>> Brent Royal-Gordon
>> Architechies
>> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list