I think you'd better define your own operator, maybe `=~` or something else. As `==` has already meant something in enum.
Zhaoxin On Mon, May 8, 2017 at 5:07 PM, Rien via swift-users <swift-users@swift.org> wrote: > I’d love to know if there is a better way, but a ‘switch’ or 'if case' is > the only way I know. > > Regards, > Rien > > Site: http://balancingrock.nl > Blog: http://swiftrien.blogspot.com > Github: http://github.com/Balancingrock > Project: http://swiftfire.nl - A server for websites build in Swift > > > > > > > > On 08 May 2017, at 11:01, Rick Mann via swift-users < > swift-users@swift.org> wrote: > > > > 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 > > rm...@latencyzero.com > > > > > > _______________________________________________ > > swift-users mailing list > > swift-users@swift.org > > https://lists.swift.org/mailman/listinfo/swift-users > > _______________________________________________ > swift-users mailing list > swift-users@swift.org > https://lists.swift.org/mailman/listinfo/swift-users >
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users