是否可纯粹从通用参数中产生一类物体? 例如:
class myclass[T] {
def something(): Class[_ <: T] =
classOf[T] //this doesn t work
}
Since the type will have been erased at runtime, it seems like this a job for manifests, but I haven t found an example that demonstrates this particular usage. I tried the following, but it doesn t work either:
class myclass[T] {
def something()(implicit m: Manifest[T]): Class[_ <: T] =
m.erasure //this doesn t work
}
我怀疑这一失败是因为,正如APICS指出的那样,在<代码>m.erasure的类型之间不存在亚类关系。 页: 1 T。
EDIT: I m not really interested in what the type T
is, I just need an object of type Class[_ <: T]
to pass to a method in the hadoop framework.
任何要点?