Pattern: Multiple closures with trailing closure
Issue: -
Trailing closure syntax should not be used when passing more than one closure argument.
Examples of correct code:
foo.map { $0 + 1 }
foo.reduce(0) { $0 + $1 }
if let foo = bar.map({ $0 + 1 }) {
}
foo.something(param1: { $0 }, param2: { $0 + 1 })
UIView.animate(withDuration: 1.0) {
someView.alpha = 0.0
}
Examples of incorrect code:
foo.something(param1: { $0 }) ↓{ $0 + 1 }
UIView.animate(withDuration: 1.0, animations: {
someView.alpha = 0.0
}) ↓{ _ in
someView.removeFromSuperview()
}