Reputation: 1290
In the code below at runtime the value will just be an instance of class list. Is it possible to create an instance of class List[T] using typetags or classtags?
private def method[T <: Product](clazz: Class[T]) = {
val value: Class[List[T]] = classOf[List[T]]
}
Upvotes: 0
Views: 64
Reputation: 56
import scala.reflect.ClassTag
def create[A: ClassTag](): List[A] = List.empty[A]
create[Int]()
Upvotes: 1