I am struggling with a problem and I can't realise how to solve it. I hope more experienced Scala programmers can shed me a light!
In scala reflection if we do the following:
case class Number(n: Int)
def getInfo[T](implicit tag: TypeTag[T]): Unit = println(tag)
we get an instance of Type :) (GREAT!). I wish I could do the same with an arbitrary class like MyTypeTag[T]:
trait MyTypeTag[T] {
}
def getInfo[T](implicit tag: MyTypeTag[T]): Unit = println(tag.hashCode)
How to do such thing? Does the scala reflection package provide some concrete implicit behind the scenes? If so, how can I accomplish the same result?
Aucun commentaire:
Enregistrer un commentaire