how do I pass an enum to a method (no reified gene...
# getting-started
b
how do I pass an enum to a method (no reified generics) and get its entries in a multiplatform project?
Copy code
import kotlin.reflect.KClass

enum class Test {
    TEST,
    TEST2,
}

fun <T> logEntries(enumClass: KClass<T>) where T : Any {
    enumClass.entries()
}

logEntries(Test::class)
s
On the JVM,
enumClass.java.enumConstants
. Not sure if it's possible in pure Kotlin.
b
should have added multiplatform
there are so many limitations on enums xD
a
I think there is an
enumEntries<Enum>()
reified function
b
yes, can only be used with reified generics though