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

Brent Royal-Gordon brent at architechies.com
Thu Dec 17 08:51:57 CST 2015


> 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.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list