Skip to content

Commit

Permalink
clarify use of self and remove non-working example kodecocodes#241
Browse files Browse the repository at this point in the history
  • Loading branch information
rayfix committed Dec 3, 2016
1 parent aaf90e7 commit 71af28e
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -372,22 +372,8 @@ The example above demonstrates the following style guidelines:

For conciseness, avoid using `self` since Swift does not require it to access an object's properties or invoke its methods.

Use `self` when required to differentiate between property names and arguments in initializers, and when referencing properties in closure expressions (as required by the compiler):
Use self only when required by the compiler (in `@escaping` closures, or in initializers to disambiguate properties from arguments). In other words, if it compiles without self then omit it.

```swift
class BoardLocation {
let row: Int, column: Int

init(row: Int, column: Int) {
self.row = row
self.column = column

let closure = {
print(self.row)
}
}
}
```

### Computed Properties

Expand Down

0 comments on commit 71af28e

Please sign in to comment.