lundi 21 mars 2016

Instantiating all classes that extend trait in Scala

So I'm building a library, and the problem I have is as follows:

I have a trait, such as

trait Animal {
  def randomFunctions
}

What I need to know is all the classes the library's user has, that extend said trait, such as

case class Cat extends Animal
case class Dog extends Animal

And as I said those subclasses wouldn't be included in the library which contains the trait (and where I need to work my magic)





Aucun commentaire:

Enregistrer un commentaire