📜  kotlin 枚举 - Kotlin 代码示例

📅  最后修改于: 2022-03-11 14:53:33.792000             🧑  作者: Mango

代码示例2
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) 
    }
}