lundi 2 juillet 2018

How to check whether a type is an enum in Kotlin?

At runtime, I am trying to verify whether a particular KClass<out Any> is an enum type or not.

What is the best way to do so? Can this be done without relying on a particular runtime (e.g., JVM or JS)?

fun isEnum( type: KClass<out Any> ): Boolean
{
    ... ?
}





Aucun commentaire:

Enregistrer un commentaire