ios – Easy methods to I solid a sort to a variable in an enum inside a swap assertion?

[ad_1]

Sample matching of enums with related values is composable, so you are able to do this:

swap error {
case Venture.Shopper.LoadError.operationFailed(Venture.Shopper.APIClientError.invalidStatusCode("error" , _)):
    delegate?.error(invalidScript)
default:
    refresh()
}

You would possibly discover that this can be a bit onerous to learn due to how lengthy these fully-qualified type-names are.

I believe the kind of error is the overall Error, however in different instances, if the kind of error is already-known to be Venture.Shopper.LoadError, then you may simply use .operationFailed (leaving the kind to be inferred from context). And if .operationFailed‘s related kind is thought to have kind Venture.Shopper.APIClientError, you may simply use .invalidStatusCode.

If not, you should use some native type-aliases might help with that:

typealias LoadError = Venture.Shopper.LoadError
typealias APIClientError = Venture.Shopper.APIClientError

swap error {
case LoadError.operationFailed(APIClientError.invalidStatusCode("error", _)):
    delegate?.error(invalidScript)
default:
    refresh()
}

[ad_2]

Leave a Reply