<html><head><meta http-equiv="Content-Type" content="text/html charset=gb2312"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi, All: <div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>trailing closure is good for most cases, but sometimes it is also make code unclear, for example: </div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIView</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">animateWithDuration</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0.3</span>, animations: { () -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>// animation code here</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> }) { (Bool) -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>// completion code here</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div><div class="">the label been removed and the code also not aligned well. </div><div class="">I would like to write like this: </div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>animateWithDuration<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0.3</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">,</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> animations: { () -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>// animation code here</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> },</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> completion: { Bool -> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>// completion code here</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">It is possible, just every time you have to write it manually. It¡¯s a little wast.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">So I have a thought, since we already know this function is not well suit for trailing </div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">closure, can we add a attribute to disable it, for example: </div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><div style="margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class="">extension<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""> <font color="#ff2807" class="">@disable_trailing_closure</font></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class=""> public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">static</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> animateWithDuration(duration:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSTimeInterval</span>, animations:()-><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span>, completion:()-><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span>) {</div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>// implementations ...</div><div style="margin: 0px; line-height: normal;" class=""> }</div><div style="margin: 0px; line-height: normal;" class="">}</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">I also found another one have issue for this too. link: <a href="http://www.natashatherobot.com/swift-trailing-closure-syntax/" class="">http://www.natashatherobot.com/swift-trailing-closure-syntax/</a></div><div style="margin: 0px; line-height: normal;" class="">what do you think?</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Best Regards</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">ChenYungui</div></div></body></html>