3 ms·
This only pushes the responsibility down lower in the stack. Somewhere someone would have to handle a state where we have data and error being nil at the same
by m3kw9 8y ago
This only pushes the responsibility down lower in the stack. Somewhere someone would have to handle a state where we have data and error being nil at the same time.
- minfduck 8y agoNo it doesn't. This article is specifically about how you can use the Swift type system to prevent that from happening. You get a compile time guarantee that the result will either be data or error.
- m3kw9 8y agoThe server can a aboulutly send you data and error as nil, either by error or on purpose. Someone is gonna handle that.
- cnowacek 8y agoNot necessarily. The way that the enumerated type is declared, the associated types of the success and failure values are declared to be normal (not optional). This restricts nil from being passed in as the data or the error.
- solidsnack9000 8y agoActually, it puts the responsibility higher in the stack. The first error effectively terminates the computation, so subcomputations can ignore them and the caller can decide what to do with them. One good thing about this is not having to push down anything to do with logging or reporting into subcomputations.