4 ms·
Maintaining State in Your ViewControllers – Swift
- Chazprime 8y agoThis is a pattern that I've started using everywhere and it's incredibly useful. The common closure format of: (T?, Error?) -> () means you have possibly four different options for the return value, it's much simpler to represent as: enum Result<T> { case success(T) case error(Error) } Here's a great read about how Swift enums are algebraic sum types: https://mislavjavor.github.io/2017-04-19/Swift-enums-are-sum-types.-That-makes-them-very-interesting/ https://mislavjavor.github.io/2017-04-19/Swift-enums-are-sum...