> On May 10, 2017, at 2:05 AM, Rick Mann <rm...@latencyzero.com> 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
> 
> Maybe swift could provide a 'case==()' so one needn't write this (I can see 
> it getting quite tedious and error-prone, should one forget to update the 
> equality after adding additional cases).


There's been some talk on swift-evolution about synthesizing an `Equatable` 
implementation for enums with associated types, but that would not implement 
your slightly weird equality semantic—it would compare the associated types, 
which isn't what you want. The same would undoubtedly be true for any other 
syntactic sugar we might provide. So I wouldn't hold your breath waiting for a 
better way to implement it than this.

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to