Johannes Zick
04/06/2020, 4:30 PMval o = Option.just(1)
val i: Int = when (o) {
is Some -> {
val (value) = o
value
}
else -> 0
}
val i: Int = when (o) {
is Some(value) -> value
else -> 0
}
This should be exactly equivalent, it could even result in exactly the same bytecode. It's easy to provide conversions in the IDE, one way or another. And it could give a hint if people really use this or if it's just a reflex to want everything others have (not even sure about myself, if we are being honest here).
It could be extended in the future, to also do type checks on destructured values (great for Pair), or other checks. Or not. By tying it to the is
keyword for now, it's still open if this syntax will be extended, or dropped again, or will be replaced by something more powerful with a different keyword.Johannes Zick
04/08/2020, 8:43 AMDico
04/08/2020, 9:20 AMDico
04/08/2020, 9:20 AMRuckus
04/08/2020, 2:09 PMOption
type.Johannes Zick
04/08/2020, 2:19 PMHanno
04/08/2020, 7:14 PMJohannes Zick
04/09/2020, 7:52 AMJohannes Zick
04/09/2020, 7:52 AMHanno
04/10/2020, 11:18 AMJohannes Zick
04/14/2020, 7:51 AM