vendredi 23 novembre 2018

Scala reflection: can I see if something is a (case) object?

Is there a way in Scala to see if a class was defined as an object?

def isObject(c: Class[_]): Boolean = ???

object X
class Y

val x = X
val y = new Y

isObject(x.getClass) == true
isObject(y.getClass) == false





Aucun commentaire:

Enregistrer un commentaire