0

If I have some class heirarchy defined like this

sealed trait A case class B() extends A case class C() extends A // and so on ..

and in a different location I want to call some method dynamically passing above classes as type to that function

(eg: method[B](..){..} or method[C](..){..})

How can this be achieved at runtime?

Harsh Gupta
  • 339
  • 4
  • 20
  • Depends on what you intend to do with that information. I am guessing, that you are looking for `Manifest`, but it is very hard to tell for sure from your description of the problem. – Dima May 26 '16 at 00:27
  • How does it depend on what I intend to do with the information ? Also isn't `Manifest` deprecated ? – Harsh Gupta May 26 '16 at 00:31
  • Because depending on what you want to do with information you need different information. For example, if you just wanted to print it out, then you can pass the class name down. If you want to call a method defined on the class, you just need an instance of that class ... etc. Manifest is not deprecated yet. They say, it will be replaced by `ClassTag` eventually, but it is actually just an alias for `ClassTag`, so there isn't much difference. And I personally like the name better. – Dima May 26 '16 at 01:12

0 Answers0