<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></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 Apr 18, 2016, at 11:42 AM, Peter Eddy via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello,<div class=""><br class=""></div><div class="">I'd like to understand why I'm unable to use the nil coalescing operator with functions.</div><div class=""><br class=""></div><div class="">For example, I'd like to write a function that takes an optional function as a parameter and that uses the nil coalescing operator to select a default function if the function's &nbsp;function parameter is nil, e.g:</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; &nbsp; func test(x: ((String) -&gt; String)? = nil) {</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp; let qq = { (p:String) -&gt; String in return "..." }</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp; let fn: String -&gt; String = x ?? qq</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp; fn("test")</div><div class="">&nbsp; &nbsp; }</div></div><div class=""><br class=""></div><div class="">When I do this the compiler complains that:</div><div class=""><br class=""></div><div class="">&nbsp; Binary operator '??' cannot be applied to operands of type '((String) -&gt; String)?' and '(String) -&gt; String:</div><div class=""><br class=""></div><div class="">In the Swift 2.2 Language Guide (<a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/BasicOperators.html" class="">https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/BasicOperators.html</a>) it states:</div></div></div></blockquote><br class=""></div><div>This is a bug, which has already been fixed in master. &nbsp;The fix will go out with Swift 3.</div><div><br class=""></div><div>-Chris</div><br class=""></body></html>