I have a general enum implementation with traditional key-value attributes:
enum class FooEnum(val key : String, val value : Any) {
FOO1("FOO_KEY", "FOO_VALUE"),
FOO2("FOO_KEY2", 0);
companion object {
fun getKeyValuesMap(): Map<String, Any> {
val defaults = HashMap<String, Any>()
for (v in values())
defaults[v.key] = v.value
return defaults
}
}
}
Is there a better "Kotlin" way to achieve the same result of getKeyValuesMap() ?