「Kotlin入門」when式にelseを使うサンプル
構文
when(条件){
数値1->xx
数値2->
else->
}
サンプルコード
when (x) {
11 -> print("x == 11")
22 -> print("x == 22")
else -> {
print("not 11 and 22")
}
}
Coding Changes the World
構文
when(条件){
数値1->xx
数値2->
else->
}
サンプルコード
when (x) {
11 -> print("x == 11")
22 -> print("x == 22")
else -> {
print("not 11 and 22")
}
}