You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
***3.8.3** If specifying a closure as a type, you don’t need to wrap it in parentheses unless it is required (e.g. if the type is optional or the closure is within another closure). Note that using `Void` is preferred to using `()` because the `()`can become difficult to read once wrapped in multiple sets of parentheses.
700
+
***3.8.3** If specifying a closure as a type, you don’t need to wrap it in parentheses unless it is required (e.g. if the type is optional or the closure is within another closure). Always wrap the arguments in the closure in a set of parentheses - use `()`to indicate no arguments and use `Void` to indicate that nothing is returned.
701
701
702
702
```swift
703
-
let completionBlock: Void->Void= {
703
+
let completionBlock: (success: Bool) ->Void= {
704
+
print("Success? \(success)")
705
+
}
706
+
707
+
let completionBlock: () ->Void= {
704
708
print("Completed!")
705
709
}
706
710
707
-
let completionBlock: (Void->Void)?=nil
711
+
let completionBlock: (()->Void)?=nil
708
712
```
709
713
710
714
***3.8.4** Keep parameter names on same line as the opening brace for closures when possible without too much horizontal overflow (i.e. ensure lines are less than 160 characters).
0 commit comments