8000 Prefer implicit getters on computed properties · smashcoding/swift-style-guide@798fe29 · GitHub
[go: up one dir, main page]

Skip to content

Commit 798fe29

Browse files
committed
Prefer implicit getters on computed properties
Proposed by @robrix in ReactiveCocoa/ReactiveCocoa#1382 (comment). /cc @github/mac
1 parent e128d20 commit 798fe29

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
swift-style-guide
2-
=================
1+
##### Prefer implicit getters on computed properties
32

4-
Style guide & coding conventions for Swift projects
3+
Prefer:
4+
5+
```swift
6+
var myGreatProperty: Int {
7+
return 4
8+
}
9+
```
10+
11+
over:
12+
13+
```swift
14+
var myGreatProperty: Int {
15+
get {
16+
return 4
17+
}
18+
}
19+
```
20+
21+
_Rationale:_ The intent and meaning of the first version is clear, and results in less code.

0 commit comments

Comments
 (0)
0