Files
kotlin-fork/compiler/testData/ir/irText/expressions/when.kt
T
Dmitry Petrov 0b647ac358 Basic class members generation.
Split testData into 'classes' and 'expressions'.
2016-10-18 09:08:32 +03:00

27 lines
622 B
Kotlin
Vendored

object A
fun testWithSubject(x: Any?) =
when (x) {
null -> "null"
A -> "A"
is String -> "String"
in setOf<Nothing>() -> "nothingness?"
else -> "something"
}
fun test(x: Any?) =
when {
x == null -> "null"
x == A -> "A"
x is String -> "String"
x in setOf<Nothing>() -> "nothingness?"
else -> "something"
}
fun testComma(x: Int) =
when (x) {
1, 2, 3, 4 -> "1234"
5, 6, 7 -> "567"
8, 9 -> "89"
else -> "?"
}