Skip to content

Commit

Permalink
Disallow single letter type variables for rule 2.6 (#16)
Browse files Browse the repository at this point in the history
* Disallow single letter type variables in rule 2.6

* changed Last Updated date, also renamed `flatten` to `joined`
  • Loading branch information
rkgibson2 authored and cezarywojcik committed Sep 26, 2017
1 parent 54483bb commit 7bc410c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Make sure to read [Apple's API Design Guidelines](https://swift.org/documentatio

Specifics from these guidelines + additional remarks are mentioned below.

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

## Table Of Contents

Expand Down Expand Up @@ -211,10 +211,9 @@ class MyClassName {
}
```

* **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.
* **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.

```swift
class SomeClass<T> { /* ... */ }
class SomeClass<Model> { /* ... */ }
protocol Modelable {
associatedtype Model
Expand Down Expand Up @@ -731,7 +730,7 @@ doSomething(1.0, success: { (parameter1) in

* **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.

* **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()`.
* **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()`.

### 3.10 Error Handling

Expand Down

0 comments on commit 7bc410c

Please sign in to comment.