jeudi 24 décembre 2020

In scala how to determine whether a class object implements a trait

It is something as the code below. I found isAssignableFrom in Java but it's not in scala.

  trait A

  def isTraitA(c:Class[_]) = {
    // check if c implements A
    // something like 
    // classOf[A].isAssignableFrom(c) 
  }
  
  isTraitA(this.getClass)




Aucun commentaire:

Enregistrer un commentaire