title: Different types in Map Scala
body: <p>I need a Map where I put different types of values (Double, String, Int,...) in it, key can be String.</p>
  
  <p>Is there a way to do this, so that I get the correct type with <code>map.apply(k)</code> like</p>
  
  <pre><code>val map: Map[String, SomeType] = Map()
  val d: Double = map.apply("double")
  val str: String = map.apply("string")
  </code></pre>
  
  <p>I already tried it with a generic type</p>
  
  <pre><code>class Container[T](element: T) {
      def get: T = element
  }
  
  val d: Container[Double] = new Container(4.0)
  val str: Container[String] = new Container("string")
  val m: Map[String, Container] = Map("double" -&gt; d, "string" -&gt; str)
  </code></pre>
  
  <p>but it's not possible since <code>Container</code> takes an parameter. Is there any solution to this?</p>