title: putting a generic type in a scala list
body: <p>I'm trying to create a generic type and putting them into a list. Here's my code.</p>
  
  <pre><code>class A
  class B extends A
  class C extends B
  
  class G[T &lt;: B] {
    def x(t: T) = {}
  }
  
      val g1 = new G[B]
      val g2 = new G[C]
  
      //val list1: List[G[B]] = List(g1, g2) -- this would not compile.
      val list: List[G[_ &lt;: B]] = List(g1, g2)
      list.head.x()//now what ?
  </code></pre>
  
  <p>I was expecting type for x would be B but instead compiler complains about</p>
  
  <pre><code>_$1 where type _$1 &lt;: com.example.cake.modules.robotics.B
      list.head.x(new B)
  </code></pre>
  
  <p>Quick googling the problem pointed to me to the wild card (_ &lt;: B). however not sure how to fix. </p>