Quantcast
Channel: Kotlin: convert from int to Enum - Stack Overflow
Browsing latest articles
Browse All 2 View Live

Answer by Mariell Hoversholm for Kotlin: convert from int to Enum

The easiest way would be using first (it also has a firstOrNull alternative) like so:val results = ints.mapIndexed { idx, e -> getRomanDigit(e, Rank.values().first { it.value == ints.size - idx })...

View Article


Kotlin: convert from int to Enum

Is it possible to convert from int to my Enum in Kotlin?I have the Enum:enum class Rank(val value: Int) { UNITY(1), TEN(2), HUNDRED(3), THOUSAND(4) }And I want to call something like:val results =...

View Article
Browsing latest articles
Browse All 2 View Live