https://kotlinlang.org logo
#reflect
Title
# reflect
v

v79

03/30/2018, 7:42 PM
Can reflection tell me if a KClass is an enum or not? There doesn't seem to be an isEnum method.
b

beholder

03/30/2018, 8:08 PM
Maybe
kClass.isSubclassOf(Enum::class)
v

v79

03/30/2018, 8:13 PM
Thanks. I'll try that out. I hope nobody writes complex nested enums!
r

Rafael Chaves

04/10/2018, 10:53 PM
On the JVM, you can use java.lang.Class#isEnum()
2 Views