<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 29, 2016 at 2:49 PM, Nate Cook via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> On Apr 29, 2016, at 1:57 PM, Wolfgang H. via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
> Inconsistency A. is that “Set” currently is the only collection type conforming to protocol 'Hashable'”. IMHO both “Array” and “Dictionary” should conform to protocol “Hashable”, too.<br>
<br>
</span>Set is the only Hashable* collection type because it's the only collection type where all of its values are always Hashable themselves. Array<Element> can be an array of a non-Hashable type; Dictionary<Key: Value> can have a non-Hashable type for Value. If/when Swift gains conditional protocol compliance, arrays and dictionaries of Hashable types could themselves be Hashable, but not until then.<br>
<span class=""><br>
> Inconsistency B. is that “Array<Int>” is typesafe if used as element of an “Array” but is non-typesafe if used as element of “Set” or “Dictionary”. The non-typesafety may result from the mapping of “Array<Int>” to “NSArray“.<br>
<br>
</span>Since Array<Element> isn't Hashable, you can't create a Set<Array<Int>>. The type system therefore falls back to using the bridged Objective-C type for Array<Int>, which can provide a hash value based on object identity.<br>
<br>
Nate<br>
<br>
<br>
*For my spell checker's sake, could we rename Hashable to Washable? Thanks</blockquote><div><br></div><div><br></div><div>Well put, Nate.</div><div>It will be a great day when conditional protocol compliance comes to Swift. Until then, there's good reason why Array and Dictionary can't be washed.</div></div><br></div></div>