ok, this: ``` enum class ABCEnum(val id: Int) { ...
# getting-started
a
ok, this:
Copy code
enum class ABCEnum(val id: Int) {
    A(10), B(30), C(40);
    
    companion object {
        private val enumMap = values().associateBy { it.id }
        fun fromId(id: Int): ABCEnum = enumMap[id] ?: throw IllegalArgumentException("Invalid ID")
    }
}

fun foo() {
    val someABC = ABCEnum.fromId(30)
}