<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 May 12, 2016, at 11:38 PM, Tyler Fleming Cloutier 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello everyone,<div class=""><br class=""></div><div class="">It does seem like it is currently possible to wrap just the function declaration in an #if swift() directive like so:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(120, 73, 42);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#if</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">swift</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(>=</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3.0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> add(</span><span style="font-variant-ligatures: no-common-ligatures" class="">filter filterName: </span><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="color: rgb(112, 61, 170);" class="">String</span>, path: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class="">) {</span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal; color: rgb(120, 73, 42);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#else // ERROR Expected ā}ā at end of brace statement</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="font-family: Helvetica; font-size: 12px;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">public</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> addFilter(</span><span style="font-variant-ligatures: no-common-ligatures;" class="">filterName: </span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="color: rgb(112, 61, 170);" class="">String</span>, path: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">String</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) {</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(120, 73, 42);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">#endif</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">Is it possible Iām missing how to do this? This is particularly painful in Swift 3 given the change to move have labels on the first function parameter by default. As far as I can see it means that I am required to wrap the entire function body even if nothing else is incompatible with Swift 3.</span></div></span></div></div></span></div></div></div></div></blockquote><br class=""></div><div>Alternatively, you could move the function body out to a separate closure and call it from differentiated 3 and 2.2 signatures.</div><div><br class=""></div><div>I may have written a blog post about this this morning.</div><div><br class=""></div><div>-- Erica</div><div><br class=""></div><br class=""></body></html>