SE-0279: Multiple Trailing Closures [Amended]

Personally, I would say no to both comments and labels on new lines.

There does not appear to be a precedent for the compiler restricting types of comments based on context, and anything more than a single line comment gets in the way of reading the statement. For example:

UIView.animate(withDuration: 0.3) {
    self.view.alpha = 0
}
/*
As soon as the animation is over, we can remove the view.
We also need to stop the mouse before it eats all our cheese.

TODO: Stop *all* mice from eating cheese if more than one mouse is present.
*/
completion: { _ in
    self.view.removeFromSuperview()
    self.mouse.stopEatingCheese()
}

As for labels on new lines, I believe it adds ambiguity because it puts the label at the same indentation/level-of-importance as the main statement (making it much easier to confuse with an independent statement). That said, just making sure there are no empty lines between closures is a vast improvement.

1 Like