<p dir="ltr"><br>
var someInteger = 250<br>
if 200..<299 ~= someInteger {<br>
print("works")<br>
}</p>
<br><div class="gmail_quote"><div dir="ltr">Em sáb, 26 de mar de 2016 18:47, Maury Markowitz via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Before I stick my head into the other list, consider:<br>
<br>
if statusCode >= 200 && statusCode <= 299<br>
<br>
I'm sure examples of something like this occur throughout your code. But the actual semantics of the test is hidden here, you're really testing if statusCode lies within a range. Swift 2.0 has a couple of options for this, but I find them all rather odd. The most recommended is:<br>
<br>
if case 0...100 = someInteger<br>
<br>
This syntax has problems. For one thing, it's written backwards compared to most people's code...<br>
<br>
if someinteger == 100<br>
<br>
not...<br>
<br>
if 100 == someinteger<br>
<br>
so it just *feels* wrong. In addition, the use of "case" seems odd too. And finally, there's the use of the single equals sign in a test, which goes against everything we've learned in C-like languages.<br>
<br>
So unless I'm missing something, can anyone offer a reason this wouldn't work?<br>
<br>
if someinteger in 0...100<br>
<br>
<br>
_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
</blockquote></div>