when {
list.all { it < 10 } -> foo()
list.any { it % 2 == 0 } -> bar()
else -> baz()
}
(I hope I got the terminology somewhat right 😬)
✅ 3
v
Vadim Kapustin
06/18/2021, 7:15 AM
And 'when' matches its argument against all branches sequentially until some branch condition is satisfied. So if you expect 'foo' and 'bar' to work, then you need to do something like this:
Copy code
with(list) {
var noMatch = true
if (all { it < 10 }) {
foo()
noMatch = false
}
if (any { it % 2 == 0 }) {
bar()
noMatch = false
}
if (noMatch) baz()
}
m
mzgreen
06/18/2021, 7:42 AM
makes sense now, thanks!
what do you mean by saying that it doesn't put its argument into scope yet? Are there plans to change it? Do you have a tracking ticket link or something?
r
Ruckus
06/18/2021, 1:39 PM
There are a number of open issues / proposals to augment the functionality of