[swift-evolution] Limit checking syntax

Vladimir.S svabox at gmail.com
Fri Apr 8 08:13:33 CDT 2016


On 08.04.2016 4:14, Harlan Haskins via swift-evolution wrote:
 > I’ve found that .contains works well for all my uses.
 >
 > (0..<100).contains(x)

Hmm.. Isn't next construction is much more readable?:

x.in(0..<100)

I think it is much more readable.
We are planning(in head) to verify "if x value is in range from 0 up to 
99", so why we have to write "for some range 0 to 9 let's check if it 
contains our x value".
Our x is a subject of our check, not range (0..<100).

I.e. in my opinion -1 for 'in' operator like suggested in initial message,
but +1 for .in method for integer to check against range
Any additional opinion?

Vladimir
(P.S. Sorry for duplicate.)


More information about the swift-evolution mailing list