Answers for "how to use enum in kotlin"

2

how to use enum in kotlin

enum class RGB { RED, GREEN, BLUE }

inline fun <reified T : Enum<T>> printAllValues() {
    print(enumValues<T>().joinToString { it.name })
}

printAllValues<RGB>() // prints RED, GREEN, BLUE
Posted by: Guest on June-19-2021

Browse Popular Code Answers by Language