(Kotlin 1.1) sealed class Color object Red : Color() object Green : Color() object Blue : Color() data class RGB(val r: Int, val g: Int, val b: Int) : Color() fun value(color: Color) = when(color){ Red -> "#FF0000" Green -> "#FF0000" Blue -> “#FF0000" is RGB -> color.let { (r, g, b) -> “#%02X%02X%02X".format(r, g, b) } } Destructuring in Lambdas (since 1.1)