<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=""><blockquote type="cite" class="">On Aug 15, 2016, at 3:08 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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; float: none; display: inline !important;" class="">On Mon, Aug 15, 2016 at 3:05 PM, Charles Srstka<span class="Apple-converted-space"> </span></span><span dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><<a href="mailto:cocoadev@charlessoft.com" target="_blank" class="">cocoadev@charlessoft.com</a>></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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; float: none; display: inline !important;" class="">wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><blockquote class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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; 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 style="word-wrap: break-word;" class=""><span class=""><blockquote type="cite" class="">On Aug 15, 2016, at 2:27 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class=""></blockquote><div class=""><blockquote type="cite" class=""><br class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline !important;" class="">`let value = (x == nil) ? nil : foo.bar(x: x)` isn't so bad, is it? You could even write a custom operator to sugar it.</span></div></blockquote></div><br class=""></span><div class="">It’s distasteful, due to the need to use the force-unwrap operator. In cases like this, I usually end up writing:</div><div class=""><br class=""></div><div class="">let value: Foo? = nil</div><span class=""><div class=""><br class=""></div><div class="">if let x = x {</div></span><div class=""><span style="white-space: pre-wrap;" class="">        </span>value = foo.bar(x: x)</div><div class="">} else {</div><div class=""><span style="white-space: pre-wrap;" class="">        </span>value = nil</div><div class="">}</div><div class=""><br class=""></div><div class="">or:</div><div class=""><br class=""></div><div class="">let value: Foo? = {</div><span class=""><div class=""><span style="white-space: pre-wrap;" class="">        </span>if let x = x {</div></span><div class=""><span style="white-space: pre-wrap;" class="">                </span>return foo.bar(x: x)</div><div class=""><span style="white-space: pre-wrap;" class="">        </span>} else {</div><div class=""><span style="white-space: pre-wrap;" class="">                </span>return nil</div><div class=""><span style="white-space: pre-wrap;" class="">        </span>}</div><div class="">}()</div><div class=""><br class=""></div><div class="">Both of which are unwieldy, but necessary to avoid the use of !.</div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class="">You are arguing that the force unwrap operator ! is, per se, distasteful?</div></div></blockquote></div><br class=""><div class="">If there are two ways to do something, and one uses the force-unwrap operator while the other does not, I’ll usually opt for the latter.</div><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></body></html>