enum class Color { RED, GREEN, BLUE } fun main() { println(Color.GREEN) // GREEN }
Or give enum a value:
enum class Color { RED(0xFF0000), GREEN(0x00FF00), BLUE(0x0000FF) }
Give a method:
enum class Color(val rgb: Int) { RED(0xFF0000), GREEN(0x00FF00), BLUE(0x0000FF); // need ; split enum and fun fun containRed() { return this.rgb and 0xFF0000 != 0 } } // Color.RED.containRed() // true