8000 Put the colon after the key type for dictionaries · dxq-git/swift-style-guide-1@e62e45b · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit e62e45b

Browse files
committed
Put the colon after the key type for dictionaries
1 parent 65797b5 commit e62e45b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ func makeCoffee(type: CoffeeType) -> Coffee { ... }
134134
_Rationale:_ The type specifier is saying something about the _identifier_ so
135135
it should be positioned with it.
136136

137+
#### When declaring a dictionary type, always associate the colon with the key
138+
139+
When specifying the type of a dictionary, always put the colon immediately
140+
after the key type, followed by a space and then the value type.
141+
142+
```swift
143+
let capitals: [Country: City] = [
144+
Sweden: Stockholm
145+
]
146+
```
147+
137148
#### Only explicitly refer to `self` when required
138149

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

0 commit comments

Comments
 (0)
0