In Swift 5 Apple introduced Result
type. It's generic enum with two cases:
public enum Result<Success, Failure: Error> {
case success(Success), failure(Failure)
}
Personally I used to two separate completions in network calls success: Completion
and failure: Completion
, but from what I see now, Apple pushing us to use single completion with Result
type and then inside perform switch. So what are advantages of this approach with Result
? Because in a lot of cases I can just omit error handling and don't write this switch
. Thanks.