Re: [swift-users] Making Error sub-enums Equatable

2017-05-10 Thread Brent Royal-Gordon via swift-users
> On May 10, 2017, at 2:05 AM, Rick Mann wrote: > > This seems so obvious that I feel like it should be provided by the language > by default. I suppose you can make it even more compact with > >case (.one, .one), > (.two, .two), > (.three, .three): > return true > >

Re: [swift-users] Making Error sub-enums Equatable

2017-05-10 Thread Ronaldo Faria Lima via swift-users
Rigorously, one should avoid to force the purpose of a given feature of a language or library construct. If you use Equatable, you must take into account the associated values for the sake of semantics. However, you are free to create your own infix operator that could allow you compare your en

Re: [swift-users] Making Error sub-enums Equatable

2017-05-10 Thread Quinn "The Eskimo!" via swift-users
On 10 May 2017, at 09:23, Brent Royal-Gordon via swift-users wrote: > (given your "ignore the associated type" semantic) This is the bit that worries me. The docs for `Equatable` are very clear that it implies /substitutability/, which is not the case if you ignore the associated values. <

Re: [swift-users] Making Error sub-enums Equatable

2017-05-10 Thread Rick Mann via swift-users
> On May 10, 2017, at 01:23 , Brent Royal-Gordon wrote: > >> On May 8, 2017, at 2:01 AM, Rick Mann via swift-users >> 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).

Re: [swift-users] Making Error sub-enums Equatable

2017-05-10 Thread Brent Royal-Gordon via swift-users
> On May 8, 2017, at 2:01 AM, Rick Mann via swift-users > 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(S

Re: [swift-users] Making Error sub-enums Equatable

2017-05-08 Thread Zhao Xin via swift-users
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 wrote: > I’d love to know if there is a better way, but a ‘switch’ or 'if case' is > the only way I know. > > Re

Re: [swift-users] Making Error sub-enums Equatable

2017-05-08 Thread Rien via swift-users
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

[swift-users] Making Error sub-enums Equatable

2017-05-08 Thread Rick Mann via swift-users
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