<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 18 Oct 2016, at 09:58, Седых Александр via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<div class="">This code work: <br class=""><br class=""><p style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" data-mce-style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #ba2da2;" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" data-mce-style="font-variant-ligatures: no-common-ligatures;" class=""> one: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #703daa;" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures;" data-mce-style="font-variant-ligatures: no-common-ligatures;" class="">? = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #272ad8;" class="">5</span></p><p style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" data-mce-style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #ba2da2;" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" data-mce-style="font-variant-ligatures: no-common-ligatures;" class=""> two = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #272ad8;" class="">5</span></p><p style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" data-mce-style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #ba2da2;" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" data-mce-style="font-variant-ligatures: no-common-ligatures;" class=""> result = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #4f8187;" class="">one</span><span style="font-variant-ligatures: no-common-ligatures;" data-mce-style="font-variant-ligatures: no-common-ligatures;" class=""> == </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #4f8187;" class="">two</span></p><div style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><p style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: #4f8187;" data-mce-style="margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: #4f8187;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #3e1e81;" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #000000;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures;" data-mce-style="font-variant-ligatures: no-common-ligatures;" class="">result</span><span style="font-variant-ligatures: no-common-ligatures;" data-mce-style="font-variant-ligatures: no-common-ligatures; color: #000000;" class="">)</span><br class=""><br class="">//print true</p><br class="">Why we can access to Optional value without unwrap within comparison operations?<br class=""></div></div></blockquote></div><br class=""><div class="">The 'one' value isn't being unwrapped; the 'two' value is being wrapped in an optional, and then compared. In effect, it's doing:</div><div class=""><br class=""></div><div class="">let result = one == Optional(two)</div><div class=""><br class=""></div><div class="">This allows you to pass in non-optional values to functions that take optional arguments, e.g.</div><div class=""><br class=""></div><div class="">func printme(_ i:Int?) { print("\(i)") }</div><div class=""><br class=""></div><div class="">printme(one)</div><div class="">printme(two)</div><div class=""><br class=""></div><div class="">Alex</div></body></html>