Hi, All:
trailing closure is good for most cases, but sometimes it is also make
code unclear, for example:
UIView.animateWithDuration(0.3, animations: { () -> Void in
// animation code here
}) { (Bool) -> Void in
// completion code here
}
the label been removed and the code also not aligned well.
I would like to write like this:
UIView.animateWithDuration(0.3,
animations: { () -> Void in
// animation code here
},
completion: { Bool -> Void in
// completion code here
}
)
It is possible, just every time you have to write it manually. It’s a little
wast.
So I have a thought, since we already know this function is not well suit for
trailing
closure, can we add a attribute to disable it, for example:
extension UIView {
@disable_trailing_closure
public static func animateWithDuration(duration:NSTimeInterval,
animations:()->Void, completion:()->Void) {
// implementations ...
}
}
I also found another one have issue for this too. link:
http://www.natashatherobot.com/swift-trailing-closure-syntax/
<http://www.natashatherobot.com/swift-trailing-closure-syntax/>
what do you think?
Best Regards
ChenYungui
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution