8000 Merge branch 'master' into jspahrsummers-patch-1 · smashcoding/swift-style-guide@fc6b1eb · GitHub
[go: up one dir, main page]

Skip to content

Commit fc6b1eb

Browse files
committed
Merge branch 'master' into jspahrsummers-patch-1
2 parents 94737f7 + 4568978 commit fc6b1eb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ then open a pull request. :zap:
1818
* Tabs, not spaces.
1919
* End files with a newline.
2020
* Make liberal use of vertical whitespace to divide code into logical chunks.
21+
* Don’t leave trailing whitespace.
22+
* Not even leading indentation on blank lines.
23+
2124

2225
#### Prefer implicit getters on read-only properties and subscripts
2326

@@ -74,6 +77,22 @@ internal struct TheFez {
7477

7578
_Rationale:_ It's rarely appropriate for top-level definitions to be specifically `internal`, and being explicit ensures that careful thought goes into that decision. Within a definition, reusing the same access control specifier is just duplicative, and the default is usually reasonable.
7679

80+
#### When specifying a type, always associate the colon with the identifier
81+
82+
When specifying the type of an identifier, always put the colon immediately
83+
after the identifier, followed by a space and then the type name.
84+
85+
```swift
86+
class SmallBatchSustainableFairtrade: Coffee { ... }
87+
88+
let timeToCoffee: NSTimeInterval = 2
89+
90+
func makeCoffee(type: CoffeeType) -> Coffee { ... }
91+
```
92+
93+
_Rationale:_ The type specifier is saying something about the _identifier_ so
94+
it should be positioned with it.
95+
7796
#### Only explicitly refer to `self` when required
7897

7998
When accessing properties or methods on `self`, leave the reference to `self` implicit by default:

0 commit comments

Comments
 (0)
0