title: How to create a list of generic case classes in Scala?
body: <p>In my web app, a user uploads different kinds of data to our server: string, excel files, ints. I want to assemble all this data in one list if possible:</p>
  
  <pre><code>object CacheII extends App{
    case class Data[TypeT](kind: String, data: TypeT)
  
    val item1 = Data("type1", "data1")
    val item2 = Data("type1", "data2")
    val item3 = Data("type2", "data1".getBytes())
    val item4 = Data("type2", "data2".getBytes())
  
    val list = List(item1, item2, item3, item4)
  
    val item5 = if(true)
      Data("type2", "data1".getBytes())
    else if(true)
      Data("type1", "data1")
    else
      Data("type3", 548)
  
    def addItem(list: List[Data[Any]], item: Data[Any]) = {
      list :+ item
    }
  
    println(addItem(list, item5))
  }
  </code></pre>
  
  <p>Compiler Error:</p>
  
  <pre><code>Error:(22, 19) type mismatch;
   found   : List[CacheII.Data[_ &gt;: Array[Byte] with String &lt;: java.io.Serializable]]
   required: List[CacheII.Data[Any]]
    println(addItem(list, item5))
                    ^
  </code></pre>
  
  <p>How to correctly create such a list of the user data?
  Is there a different/better way to do this?</p>
  
  <p>Any advice is appreciated.</p>
  
  <p>Thank you.</p>