title: Storing and Instantiating a Scala class in a container/variable
body: <p>I need to return a class based on the key string, and then instantiate the returned type. 
  For example: </p>
  
  <pre><code>class A 
  class B
  
  val keyType = Map[String, Any ???] ("a" -&gt; A, "b" -&gt; B) ??? does not work
  val t = keyType("a") ???
  val i = ??? instantiate type A
  </code></pre>
  
  <p>However, <code>"a" -&gt; A</code> does not work, furthermore, I'm not sure how to instantiate the class stored in a variable  <code>t</code>. </p>
  
  <p>What could be the solution.</p>