Quantcast
Viewing latest article 2
Browse Latest Browse All 2

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 = ints.mapIndexed { index, element -> getRomanDigit(element, Rank(ints.size - index)) }

Viewing latest article 2
Browse Latest Browse All 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>