March 2017
Intermediate to advanced
226 pages
5h 13m
English
Initializer labels allows you to announce how the information you pass will be treated and the role each value will play. Initializers aren’t sentences: Avoid making initializers sentence-like. Don’t try to form grammatical phrases, regardless of the initializer’s style (standard, required, or convenience). Initializers focus on types and arguments:
| | // yes, `Type(thing1:, thing2:)` |
| | init(thing1: T, thing2: U) |
| | |
| | // no, `Type(with:, thing2:)` |
| | init(with thing1: T, thing2: U) |
Omit first-argument labels for value-preserving type-converting initializers. When the initialization is lossless and type-converting, skip the first label Int64(myUInt32Value).
Include first-argument labels for type-narrowing converting initializers. ...
Read now
Unlock full access