This doesn't work - is there any way I can keep my code generified and somehow reflect the classOf a ClassTag??
class Foo[T : reflect.ClassTag] { def foo = classOf[T] }
<console>:7: error: class type required but T found
class Foo[T : reflect.ClassTag] { def foo = classOf[T] }
It seems this should work but alas :(
ClassTag provides an option for parents to sign up for an account and join their child's class. Your child's teacher should have added either your email address or mobile number in their class directory. In order to join the class, there's a link on the email or SMS notification that you need to click on.
ClassTag connects teachers and families with one easy-to-use app for all their communication needs. And - it's free!
Yes, that's possible.
class Foo[T: reflect.ClassTag] {
def ctag = implicitly[reflect.ClassTag[T]]
def foo: Class[T] = ctag.runtimeClass.asInstanceOf[Class[T]]
}
or shorter:
class Foo[T](implicit ctag: reflect.ClassTag[T]) {
def foo: Class[T] = ctag.runtimeClass.asInstanceOf[Class[T]]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With