March 2017
Intermediate to advanced
226 pages
5h 13m
English
A typealias creates a new name for an existing type, simplifying code. Adopt typealiases into your APIs when the alias establishes a more concrete reusable expression. Like custom operators, a typealias should be used multiple times throughout your project or have the potential to be used repeatedly by API clients. Justify your introduction of an extra layer of abstraction and an extra symbol.
Typealiases should be shorter and cleaner than the types they replace. Adding a typealias for complex or boilerplate functions is a good thing. Adding a typealias for a common type usually isn’t, unless you’re trying to differentiate a specific role for its use.
| | typealias Completion = (Result) -> Void // yes |
| | typealias ... |
Read now
Unlock full access