[swift-users] Making Error sub-enums Equatable

Ronaldo Faria Lima ronaldo at nineteen.com.br
Wed May 10 09:05:37 CDT 2017

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 enum cases the way you want. It is important, however, to be sure that it will have a semantic clear enough so someone reading your code could understand it.


Ronaldo “Clocksmith” Lima

> Em 10 de mai de 2017, à(s) 06:16, Quinn The Eskimo! via swift-users <swift-users at swift.org> escreveu:
> On 10 May 2017, at 09:23, Brent Royal-Gordon via swift-users <swift-users at swift.org> 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.
> <https://developer.apple.com/reference/swift/equatable>
> Share and Enjoy
> --
> Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

More information about the swift-users mailing list