jeudi 12 août 2021

scala get generic type by class

Is it possible pass generic parameter using class:

  def m(clazz: Class[_]): Unit = {
    m2[] //here I want to exact type (that I should have because I have Class)
  }

  def m2[C: ClassTag]() : List[C] = {
    println("hi")
    List.empty
  }

Any Ideas?





Aucun commentaire:

Enregistrer un commentaire