<div dir="ltr"><div>To me it seems logical that comparing Optional&lt;Int&gt; with Int (or another Optional&lt;Int&gt;), if it&#39;s allowed at all, should return Optional&lt;Bool&gt;. Since conditional statements only accept Bool, the user is forced to handle the nil case explicitly.<div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Thu, Dec 3, 2015 at 4:33 PM, Kevin Ballard <span dir="ltr">&lt;<a href="mailto:kevin@sb.org" target="_blank">kevin@sb.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><u></u>




<div><div>I completely disagree. Being able to compare `Optional` values is very handy in a lot of cases. Adding special syntax for this is just unnecessary language complication, especially as the proposed syntax conflicts with the existing meaning of the postfix-? operator and the optional-chaining operator.<br></div>
<div> </div>
<div>-Kevin Ballard</div><div><div class="h5">
<div> </div>
<div>On Thu, Dec 3, 2015, at 04:17 PM, Jacob Bandes-Storch wrote:<br></div>
</div></div><blockquote type="cite"><div><div class="h5"><div dir="ltr"><div>Agreed — or, I think, these operators could/should simply be removed.<br></div>
<div> </div>
<div>I filed &lt;rdar://22833869&gt; about this a while ago, which was marked as Duplicate/&lt;rdar://16966712&gt;.<br></div>
<div> </div>
<div><pre style="outline:none;font-family:inherit;font-size:13px;margin-top:0px;margin-bottom:0px;padding:0px;white-space:pre-wrap;word-wrap:break-word;color:rgb(0,0,0)"><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>Summary:<br></div>
<div>This returns true:
    (nil as Int?) &lt; 0
This also returns true, which makes even less sense:
    (nil as Int?) &lt; Int.min<span style="font-family:inherit"></span><br></div>
</blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>Expected Results:<br></div>
<div>nil &lt; 0, nil &gt; 0, and nil == 0, should all be false. nil != 0 should be true.
Alternatively, just *don&#39;t* provide &lt; and &gt; operators that accept optional arguments.<span style="font-family:inherit"></span><br></div>
</blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-family:inherit"></span><br></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>Actual Results:<br></div>
<div>nil &lt; 0 is true. Others are as expected.<br></div>
</blockquote><div> </div>
<div>See also: <a href="https://twitter.com/jtbandes/status/646914031433871364" target="_blank">https://twitter.com/jtbandes/status/646914031433871364</a><br></div>
</pre></div>
<div><div> </div>
<div><div><div dir="ltr"><div>Jacob<br></div>
</div>
</div>
</div>
<div> </div>
<div><div>On Thu, Dec 3, 2015 at 3:42 PM, Amir Michail <span dir="ltr">&lt;<a href="mailto:a.michail@me.com" target="_blank">a.michail@me.com</a>&gt;</span> wrote:<br></div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>Such comparisons with optionals can result in hard to find bugs.<br></div>
<div> </div>
<div>
For example consider:<br></div>
<div> </div>
<div>
let f = x &lt; 5  // x is of type Int? and may be nil<br></div>
<div> </div>
<div>
The proposed ? suffix would be used as follows and makes the possibility of nil very clear:<br></div>
<div> </div>
<div>
let f = x? &lt; 5<br></div>
<div> </div>
<div> </div>
<div>
_______________________________________________<br></div>
<div>
swift-evolution mailing list<br></div>
<div> <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br></div>
<div> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote></div>
</div>
</div>
</div></div><div><img style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/f642e79cdc9179f85a1d5227d47c7f54fa9ed2213c9553950205001e5a4c58a5/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3148765176786c673171614a7d2236454230345272776e426e61476b4b6d4a4953655131557b4138603838346f4a4765426734535b6a5a50345e62497f4c4d62536939334579415579676940793b6d49777d2232447462387931725e665d2236444e40595d45767c6c6641377761563d684f4c645931384a4a47323c433073566a65537264554b6c475035396c4835467e4a497a686952556c45705c4542435662713376526934407a7f43607848385d603a4a596255386345714e63373742437961705f4a6369653055314d22324d223248367e6a56727647744d223244476f64677d23344d23344/open"><br></div><span class="">
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</span></blockquote><div> </div>

<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=P-2BsYbBZHRBuLDBJaL4DIKDNfkkjpROowTyRAObV11qyxsxSNYixSbG9AoNnxKQFQ3RUUbuirIAoSOJyuXpfBeAxuBLKtkGk1wvHGJl3tgbfXEODr1RqG1NOiQXfbGjt3yNmYvzzGibJlgZUL2Kg4fYk5S-2FXH6iyHO217gx5erUsarnE1zdoVqMG2GKBFtP-2F436VRxebJewGY3XJi-2BQdqj2JVFj4L0zqQXgNKKDjzM9s-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;">
</div>


<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div></div></div>