I\'m trying to find the best way to do a \'reverse lookup\' on an enum in Kotlin. One of my takeaways from Effective Java was that you introduce a static map inside the enum
Another option, that could be considered more "idiomatic", would be the following:
companion object { private val map = Type.values().associateBy(Type::value) operator fun get(value: Int) = map[value] }
Which can then be used like Type[type].
Type[type]