[swift-users] Making Error sub-enums Equatable

Rick Mann rmann at latencyzero.com
Mon May 8 04:01:34 CDT 2017


Seriously, I've been googling this for a half-hour, and I can't find an answer (everything that comes up is for ErrorType, absolutely nothing for Error).

I have an enum:

enum MyErrors : Error
{
    case one(String)
    case two
    case three(String)
}

let a: MyErrors = .one("foo")
let b = .two
let c = .towo

I want to compare them with ==, and I don't care about the associated types. I can't for the life of me figure out how without an exhaustive switch statement in a == definition. Is that the only way?

-- 
Rick Mann
rmann at latencyzero.com




More information about the swift-users mailing list