Skip to content

Commit 7bc410c

Browse files
rkgibson2cezarywojcik
authored andcommitted
Disallow single letter type variables for rule 2.6 (#16)
* Disallow single letter type variables in rule 2.6 * changed Last Updated date, also renamed `flatten` to `joined`
1 parent 54483bb commit 7bc410c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Make sure to read [Apple's API Design Guidelines](https://swift.org/documentatio
44

55
Specifics from these guidelines + additional remarks are mentioned below.
66

7-
This guide was last updated for Swift 3.0 on January 14th, 2017.
7+
This guide was last updated for Swift 3.0 on September 26th, 2017.
88

99
## Table Of Contents
1010

@@ -211,10 +211,9 @@ class MyClassName {
211211
}
212212
```
213213

214-
* **2.6** For generics and associated types, use either a single capital letter or a `PascalCase` word that describes the generic. If this word clashes with a protocol that it conforms to or a superclass that it subclasses, you can append a `Type` suffix to the associated type or generic name.
214+
* **2.6** For generics and associated types, use a `PascalCase` word that describes the generic. If this word clashes with a protocol that it conforms to or a superclass that it subclasses, you can append a `Type` suffix to the associated type or generic name.
215215

216216
```swift
217-
class SomeClass<T> { /* ... */ }
218217
class SomeClass<Model> { /* ... */ }
219218
protocol Modelable {
220219
associatedtype Model
@@ -731,7 +730,7 @@ doSomething(1.0, success: { (parameter1) in
731730

732731
* **3.9.1** In general, avoid accessing an array directly with subscripts. When possible, use accessors such as `.first` or `.last`, which are optional and won’t crash. Prefer using a `for item in items` syntax when possible as opposed to something like `for i in 0 ..< items.count`. If you need to access an array subscript directly, make sure to do proper bounds checking. You can use `for (index, value) in items.enumerated()` to get both the index and the value.
733732

734-
* **3.9.2** Never use the `+=` or `+` operator to append/concatenate to arrays. Instead, use `.append()` or `.append(contentsOf:)` as these are far more performant (at least with respect to compilation) in Swift's current state. If you are declaring an array that is based on other arrays and want to keep it immutable, instead of `let myNewArray = arr1 + arr2`, use `let myNewArray = [arr1, arr2].flatten()`.
733+
* **3.9.2** Never use the `+=` or `+` operator to append/concatenate to arrays. Instead, use `.append()` or `.append(contentsOf:)` as these are far more performant (at least with respect to compilation) in Swift's current state. If you are declaring an array that is based on other arrays and want to keep it immutable, instead of `let myNewArray = arr1 + arr2`, use `let myNewArray = [arr1, arr2].joined()`.
735734

736735
### 3.10 Error Handling
737736

0 commit comments

Comments
 (0)