Answers for "kotlin create enum"

0

kotlin enum

enum class Color(val rgb: Int) {
    RED(0xFF0000),
    GREEN(0x00FF00),
    BLUE(0x0000FF)
}
fun main() {
    val color = Color.RED
    if (color is Enum<*>) {
        println(Integer.toHexString(color.rgb)) 
        println(true) 
    }
}
Posted by: Guest on November-10-2021
0

kotlin enum

enum class OlympicMedal {
   GOLD, SILVER, BRONZE
}
Posted by: Guest on November-10-2021

Browse Popular Code Answers by Language