lovis
10/05/2017, 8:56 AMit
inside when
? what’s the status? i can’t find it 🤔genovich
10/05/2017, 8:59 AMit
inside whenkarelpeeters
10/05/2017, 9:00 AMwhen(obj.fetchState()) {
it.foo is "bar" -> println("hey")
}
gildor
10/05/2017, 9:01 AMlovis
10/05/2017, 9:01 AMgenovich
10/05/2017, 9:02 AMwhen(obj.fetchState().foo) {
is "bar" -> println("hey")
}
val a = obj.fetchState()
when {
a.foo is "bar" -> println("hey")
}
karelpeeters
10/05/2017, 9:04 AMit
stuff would make the lambda situation worse.lovis
10/05/2017, 9:06 AMval importantNumber = obj.importantNumber()
when {
importantNumber == 0 -> println("Oh my")
importantNumber < 0 -> println("This")
importantNumber > 1000 -> println("is getting")
importantNumber > 0 -> println("repetitive")
}
another solution would probably be to allow == 0
without a variable or somethingkarelpeeters
10/05/2017, 9:09 AMis 0
doesn't work?lovis
10/05/2017, 9:09 AMin (0..0)
does work 🤔 looks weird thojanvladimirmostert
10/05/2017, 9:11 AMwhen(blah) {
0 -> {}
}
lovis
10/05/2017, 9:11 AMgenovich
10/05/2017, 9:31 AMval importantNumber = obj.importantNumber()
when (importantNumber) {
0 -> println("Oh my")
in Int.MIN_VALUE..0 -> println("This")
in 1 until 1000 -> println("is getting")
else -> println("repetitive")
}
janvladimirmostert
10/05/2017, 9:36 AMwhen
is pretty flexible, you can also mix is
in there or even do 0,1,3 -> ...