<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This functionality was removed via SE-0121, back in the Swift 3 timeframe.<div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Saagar Jha</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On May 8, 2017, at 19:49, Zhao Xin <<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><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 class=""></div><div class="gmail_default"><div style="font-family: menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class=""> number:</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="">?</span></div><div style="font-family: menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> result = (</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="">number</span><span style="font-variant-ligatures:no-common-ligatures" class=""> ?? </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="">-1</span><span style="font-variant-ligatures:no-common-ligatures" class="">) > </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="">0</span><span style="font-variant-ligatures:no-common-ligatures" class=""> ? </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="">1</span><span style="font-variant-ligatures:no-common-ligatures" class=""> : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="">2</span></div><div style="font-family: menlo; margin: 0px; font-size: 11px; line-height: normal;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class=""><font face="georgia, serif" class="">Zhaoxin</font></span></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, May 9, 2017 at 1:39 AM, Erica Sadun via swift-users <span dir="ltr" class=""><<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">I believe this falls under "future directions" for comparison reform.</div><div class=""><br class=""></div><div class="">Here's an example of a short term solution: <a href="https://gist.github.com/erica/77b110e17e51dbea7d6934e6582f627f" target="_blank" class="">https://gist.github.<wbr class="">com/erica/<wbr class="">77b110e17e51dbea7d6934e6582f62<wbr class="">7f</a></div><div class=""><br class=""></div><div class="">-- E, who moved this from SE to Swift Users</div><div class=""><div class="h5"><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 8, 2017, at 10:13 AM, Saagar Jha via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class="m_-44241575443192622Apple-interchange-newline"><div class=""><div style="word-wrap:break-word" class="">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 class=""><br class=""><div class=""><div class="">if let number = number {</div><div class=""><span class="m_-44241575443192622Apple-tab-span" style="white-space:pre-wrap">        </span>let result = number > 0 ? 1 : 2</div><div class="">}</div><div class=""><br class=""></div><div class="">Either way, you’ll have to decide what you think should happen when number is nil.</div><div class=""><br class=""></div><div class=""><div class="">
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word" class="">Saagar Jha</div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 8, 2017, at 00:36, Suresh Kansujiya via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class="m_-44241575443192622Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hey,<div class=""><br class=""></div><div class="">i am using ternary operator with optional variable. like below ex.</div><div class=""><br class=""></div><div class="">
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><b class="">var number:Int?<br class=""></b><b class="">let result = number > 0 ? 1 : 2 </b></blockquote><p class="m_-44241575443192622gmail-p1" style="text-align:left"><b class="">here i am getting this waring : <font color="#bf9000" class="">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 class="">Note : i must need to use ternary operator for checking.</div><div class=""><br class=""></div><div class="">Regards</div><div class="">Suresh Kansujiya</div></div>
______________________________<wbr class="">_________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></div>______________________________<wbr class="">_________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-users</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>