title: How to create Dictionary that can hold anything in Key? or all the possible type it capable to hold
body: <p>I want to create a <code>Dictionary</code> that does not limit the key type (like <code>NSDictionary</code>)</p>
  
  <p>So I tried</p>
  
  <pre><code>var dict = Dictionary&lt;Any, Int&gt;()
  </code></pre>
  
  <p>and </p>
  
  <pre><code>var dict = Dictionary&lt;AnyObject, Int&gt;()
  </code></pre>
  
  <p>resulting</p>
  
  <pre><code>error: type 'Any' does not conform to protocol 'Hashable'
  var dict = Dictionary&lt;Any, Int&gt;()
             ^
  &lt;REPL&gt;:5:12: error: cannot convert the expression's type '&lt;&lt;error type&gt;&gt;' to type '$T1'
  var dict = Dictionary&lt;Any, Int&gt;()
             ^~~~~~~~~~~~~~~~~~~~~~
  </code></pre>
  
  <p>OK, I will use <code>Hashable</code></p>
  
  <pre><code>var dict = Dictionary&lt;Hashable, Int&gt;()
  </code></pre>
  
  <p>but</p>
  
  <pre><code>error: type 'Hashable' does not conform to protocol 'Equatable'
  var dict = Dictionary&lt;Hashable, Int&gt;()
             ^
  Swift.Equatable:2:8: note: '==' requirement refers to 'Self' type
    func ==(lhs: Self, rhs: Self) -&gt; Bool
         ^
  Swift.Hashable:1:10: note: type 'Hashable' does not conform to inherited protocol 'Equatable.Protocol'
  protocol Hashable : Equatable
           ^
  &lt;REPL&gt;:5:12: error: cannot convert the expression's type '&lt;&lt;error type&gt;&gt;' to type '$T1'
  var dict = Dictionary&lt;Hashable, Int&gt;()
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  </code></pre>
  
  <p>So <code>Hashable</code> inherited from <code>Equatable</code> but it does not conform to <code>Equatable</code>??? I don't understand...</p>
  
  <p>Anyway, keep trying</p>
  
  <pre><code>typealias KeyType = protocol&lt;Hashable, Equatable&gt; // KeyType is both Hashable and Equatable
  var dict = Dictionary&lt;KeyType, Int&gt;() // now you happy?
  </code></pre>
  
  <p>with no luck</p>
  
  <pre><code>error: type 'KeyType' does not conform to protocol 'Equatable'
  var dict = Dictionary&lt;KeyType, Int&gt;()
             ^
  Swift.Equatable:2:8: note: '==' requirement refers to 'Self' type
    func ==(lhs: Self, rhs: Self) -&gt; Bool
         ^
  Swift.Hashable:1:10: note: type 'KeyType' does not conform to inherited protocol 'Equatable.Protocol'
  protocol Hashable : Equatable
           ^
  &lt;REPL&gt;:6:12: error: cannot convert the expression's type '&lt;&lt;error type&gt;&gt;' to type '$T1'
  var dict = Dictionary&lt;KeyType, Int&gt;()
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
  </code></pre>
  
  <p>I am so lost now, how can I make compiler happy with my code?</p>
  
  <hr>
  
  <p>I want to use the dictionary like</p>
  
  <pre><code>var dict = Dictionary&lt;Any, Int&gt;()
  dict[1] = 2
  dict["key"] = 3
  dict[SomeEnum.SomeValue] = 4
  </code></pre>
  
  <hr>
  
  <p>I know I can use <code>Dictionary&lt;NSObject, Int&gt;</code>, but it is not really what I want. </p>