<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">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt; On Apr 29, 2016, at 1:57 PM, Wolfgang H. via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; Inconsistency A. is that “Set” currently is the only collection type conforming to protocol &#39;Hashable&#39;”. IMHO both “Array” and “Dictionary” should conform to protocol “Hashable”, too.<br>
<br>
</span>Set is the only Hashable* collection type because it&#39;s the only collection type where all of its values are always Hashable themselves. Array&lt;Element&gt; can be an array of a non-Hashable type; Dictionary&lt;Key: Value&gt; 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>
&gt; Inconsistency B. is that “Array&lt;Int&gt;” 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&lt;Int&gt;” to “NSArray“.<br>
<br>
</span>Since Array&lt;Element&gt; isn&#39;t Hashable, you can&#39;t create a Set&lt;Array&lt;Int&gt;&gt;. The type system therefore falls back to using the bridged Objective-C type for Array&lt;Int&gt;, which can provide a hash value based on object identity.<br>
<br>
Nate<br>
<br>
<br>
*For my spell checker&#39;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&#39;s good reason why Array and Dictionary can&#39;t be washed.</div></div><br></div></div>