Skip to content

Commit 15450b8

Browse files
authored
Merge pull request #2 from cezarywojcik/master
updating rule 3.8.3 for better Swift 3 conformance
2 parents adc11e9 + 7269052 commit 15450b8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,14 +697,18 @@ doSomethingWithClosure() { (response: NSURLResponse) -> String in
697697
}
698698
```
699699

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). 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.
701701

702702
```swift
703-
let completionBlock: Void -> Void = {
703+
let completionBlock: (success: Bool) -> Void = {
704+
print("Success? \(success)")
705+
}
706+
707+
let completionBlock: () -> Void = {
704708
print("Completed!")
705709
}
706710

707-
let completionBlock: (Void -> Void)? = nil
711+
let completionBlock: (() -> Void)? = nil
708712
```
709713

710714
* **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

Comments
 (0)