<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
> (starting a new thread by DaveA's request)<br class="">> <br class="">> There's a definition of equality that makes sense as a default for nearly every type in our system:<br class="">> <br class="">> - Basic types like IntNN, FloatNN, String, etc. have domain-defined equality,<br class="">> - Structs and tuples can be considered equal if their corresponding fields are equal,<br class="">> - Enums can be considered equal if they carry the same, equal payload,<br class=""><div class=""><br class=""></div><div class="">+1 for Equality, Comparable and Hashable especially for enums and tuples. </div><div class=""><br class=""></div><div class="">I know that equality was added for tuples but I think that enums are perfect for adding automatic generation of conformance to Equality, Comparable and Hashable. </div><div class=""><br class=""></div><div class="">Take a look at this toy example of an Enum with 9 cases</div><div class=""><br class=""></div><div class="">boiler plate to conform to Equatable</div><div class=""><a href="https://github.com/exercism/xswift/blob/master/exercises/poker/PokerExample.swift#L151-L189" class="">https://github.com/exercism/xswift/blob/master/exercises/poker/PokerExample.swift#L151-L189</a></div><div class=""><br class=""></div><div class="">boiler plate to conform to Comparable</div><div class=""><a href="https://github.com/exercism/xswift/blob/master/exercises/poker/PokerExample.swift#L191-L245" class="">https://github.com/exercism/xswift/blob/master/exercises/poker/PokerExample.swift#L191-L245</a></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">> It's my feeling that Equatable and Hashable would make a lot of sense as universal operations; I'm not so sure about Comparable.<br class="">> <br class="">> -Joe</div><div class=""><br class=""></div><div class=""><div class="">For enums a defaultComparable protocol could just rank on the order the fields are declared:</div></div><div class=""><a href="https://github.com/exercism/xswift/blob/master/exercises/poker/PokerExample.swift#L211-L212" class="">https://github.com/exercism/xswift/blob/master/exercises/poker/PokerExample.swift#L211-L212</a></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>