<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="">
I want to use instances of a custom class as Dictionary key.
<div class="">This requires the class to conform to Hashable.</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> ==(lhs:
<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
KeyType1</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
KeyType1</span>) -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
Bool</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
return</span> lhs.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span> == rhs.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span> }</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">final</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> KeyType1:
</span>Hashable<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">,
</span>CustomStringConvertible<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
let</span> id: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
String</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
init</span>(id: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
String</span>) { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span> = id }</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
var</span> hashValue: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
Int</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
id</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">hashValue</span> }</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
var</span> description: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
String</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
id </span>}</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
}</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Now I can use KeyType1 instances as key in Dictionary.</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> collection1 = [<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">KeyType1</span>(id:
<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">
&quot;foo&quot;</span>) : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
NSObject</span>()]</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Testing works fine:</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp;&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> key =
<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
collection1</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">first</span>!.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot;&nbsp; &nbsp; &nbsp; &nbsp; Key stored in collection:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">unsafeAddressOf</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(key)</span>) --
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">key</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">
&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
let</span> keyCopy = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
KeyType1</span>(id: key.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span>)</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Key copy:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">unsafeAddressOf</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(keyCopy)</span>) --
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">keyCopy</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">
&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Keys equal:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">key
</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">==</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> keyCopy</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hash values equal:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">key.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">hashValue</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
 == keyCopy.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">hashValue</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot; &nbsp; &nbsp; Collection has item for key:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">collection1</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">[key] !=
</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot;Collection has item for key copy:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">collection1</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">[keyCopy] !=
</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;Key stored in collection: 0x0000608000043d80 -- foo</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Key copy: 0x00006080000440b0 -- foo</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Keys equal: true</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hash values equal: true</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp;&nbsp; &nbsp; Collection has item for key: true</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">Collection has item for key copy: true</b></div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Next, I repeat the same set up -- but this time KeyType is a descendant of NSObject.</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> ==(lhs:
<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
KeyType2</span>, rhs: <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
KeyType2</span>) -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
Bool</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
return</span> lhs.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span> == rhs.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span> }</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">final</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> KeyType2:
</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSObject</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {
</span>// NSObject conforms to Hashable and CustomStringConvertible.</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
let</span> id: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
String</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
init</span>(id: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
String</span>) { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span> = id;
<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
super</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>() }</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
override</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
var</span> hashValue: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
Int</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
id</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">hashValue</span> }</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
override</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
var</span> description: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
String</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
id </span>}</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
}</div>
</div>
<div class=""><br class="">
</div>
<div class="">Again, I create a Dictionary based on this key class.</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> collection2 = [<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">KeyType2</span>(id:
<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">
&quot;foo&quot;</span>) : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">
NSObject</span>()]</div>
</div>
<div class=""><br class="">
</div>
<div class="">Using the same tests, they fail now.</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp;&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> key =
<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
collection2</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">first</span>!.<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot;&nbsp; &nbsp; &nbsp; &nbsp; Key stored in collection:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">unsafeAddressOf</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(key)</span>) --
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">key</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">
let</span> keyCopy = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">
KeyType2</span>(id: key.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">id</span>)</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Key copy:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">unsafeAddressOf</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(keyCopy)</span>) --
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">keyCopy</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">
<br class="">
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Keys equal:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">key
</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">==</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> keyCopy</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hash values equal:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">key.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">hashValue</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
 == keyCopy.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">hashValue</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot; &nbsp; &nbsp; Collection has item for key:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">collection2</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">[key] !=
</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp;
</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>&quot;Collection has item for key copy:
<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">
\</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">collection2</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">[keyCopy] !=
</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span>)&quot;<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div>
</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;Key stored in collection: 0x0000608000044080 -- foo</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Key copy: 0x00006080000440e0 -- foo</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Keys equal: true</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hash values equal: true</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">&nbsp;&nbsp; &nbsp; Collection has item for key: true</b></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<b class="">Collection has item for key copy: false</b></div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">What am I missing here?</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Thanks</div>
<div class=""><br class="">
</div>
<div class="">Etan</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</body>
</html>