Added switch (enum-only when) lowering
Added enum ordinal to serialization
This commit is contained in:
committed by
Sergey Bogolepov
parent
1afc5e5e90
commit
5ad749d56b
@@ -0,0 +1,9 @@
|
||||
enum class Color {
|
||||
RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW
|
||||
}
|
||||
|
||||
fun determineColor(code: Int): Color = when (code) {
|
||||
0 -> Color.BLUE
|
||||
1 -> Color.MAGENTA
|
||||
else -> Color.CYAN
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fun main(args: Array<String>) {
|
||||
println(Color.RED.ordinal)
|
||||
println(Color.GREEN.ordinal)
|
||||
println(Color.BLUE.ordinal)
|
||||
val color = when (determineColor(args.size)) {
|
||||
Color.RED -> println("r")
|
||||
Color.GREEN -> println("g")
|
||||
Color.BLUE -> println("b")
|
||||
Color.CYAN -> println("c")
|
||||
Color.MAGENTA -> println("m")
|
||||
Color.YELLOW -> println("y")
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user