<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">I wonder if it has ever been allowed? I am using Xcode and it never allows that. </div><div class="gmail_default" style="font-family:georgia,serif">For you specific question, you can use</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">var</span><span style="font-variant-ligatures:no-common-ligatures"> number:</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">Int</span><span style="font-variant-ligatures:no-common-ligatures">?</span></p>
<p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures"> result = (</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">number</span><span style="font-variant-ligatures:no-common-ligatures"> ?? </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">-1</span><span style="font-variant-ligatures:no-common-ligatures">) &gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">0</span><span style="font-variant-ligatures:no-common-ligatures"> ? </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">1</span><span style="font-variant-ligatures:no-common-ligatures"> : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">2</span></p><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)"><br></span></p><p style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)"><font face="georgia, serif">Zhaoxin</font></span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 9, 2017 at 1:39 AM, Erica Sadun via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I believe this falls under &quot;future directions&quot; for comparison reform.</div><div><br></div><div>Here&#39;s an example of a short term solution: <a href="https://gist.github.com/erica/77b110e17e51dbea7d6934e6582f627f" target="_blank">https://gist.github.<wbr>com/erica/<wbr>77b110e17e51dbea7d6934e6582f62<wbr>7f</a></div><div><br></div><div>-- E, who moved this from SE to Swift Users</div><div><div class="h5"><div><br></div><br><div><blockquote type="cite"><div>On May 8, 2017, at 10:13 AM, Saagar Jha via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-44241575443192622Apple-interchange-newline"><div><div style="word-wrap:break-word">Well, you’re not allowed to compare optionals any more. You can try binding the value to an Int, so that it’s not an optional anymore:<div><br><div><div>if let number = number {</div><div><span class="m_-44241575443192622Apple-tab-span" style="white-space:pre-wrap">        </span>let result = number &gt; 0 ? 1 : 2</div><div>}</div><div><br></div><div>Either way, you’ll have to decide what you think should happen when number is nil.</div><div><br></div><div><div>
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">Saagar Jha</div>

</div>
<br><div><blockquote type="cite"><div>On May 8, 2017, at 00:36, Suresh Kansujiya via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-44241575443192622Apple-interchange-newline"><div><div dir="ltr">Hey,<div><br></div><div>i am using ternary operator with optional variable. like below ex.</div><div><br></div><div>







<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><b>var number:Int?<br></b><b>let result = number &gt; 0 ? 1 : 2  </b></blockquote><p class="m_-44241575443192622gmail-p1" style="text-align:left"><b>here i am getting this waring : <font color="#bf9000">comparison operators with optionals were removed from the Swift Standard Library. Consider refactoring the code to use the non-optional operators</font></b></p></div><div>Note : i must need to use ternary operator for checking.</div><div><br></div><div>Regards</div><div>Suresh Kansujiya</div></div>
______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></div></blockquote></div><br></div></div></div></div>______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></div></blockquote></div><br></div></div></div><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>