title: What's the equivalent of Obj.C's NSMutableDictionary<Class, Class> in Swift?
body: <p>What's the equivalent of Obj.C's <code>NSMutableDictionary&lt;Class, Class&gt;</code> in Swift?</p>
  
  <p>I tried:</p>
  
  <pre><code>var dictionary = [AnyClass: AnyClass]()
  </code></pre>
  
  <p>However this throws the error: <code>Type 'AnyClass' (aka 'AnyObject.Type') does not conform to protocol 'Hashable'</code></p>
  
  <p>Since there can only be one class per name, we know a given class reference refers to a unique class; there is only one "String" in a given namespace. So why is this not hashable?</p>
  
  <p>I also tried:</p>
  
  <pre><code>var dictionary = NSMutableDictionary&lt;AnyClass, AnyClass&gt;
  </code></pre>
  
  <p>However this also fails with: <code>Cannot specialize non-generic type 'NSMutableDictionary'</code></p>
  
  <p>I thought Swift was supposed to be type-safe, but here the compiler is encouraging me to just throw anything into this NSMutableDictionary without type-checking it to make sure it's an AnyClass! </p>
  
  <p>Also, DO NOT lecture me about "You shouldn't be doing that in the first place," because, <em>I am not doing it</em>, it's already like that in some Objective C code that I am required to translate into Swift. I am simply trying to do it in the best possible way—if it means I must resort to a non-type-safe NSMutableDictionary, then so be it, however this seems ridiculous. </p>
  
  <p>Surely I'm missing something here... what am I missing?</p>