spnda
01/07/2021, 10:46 PMwhen {
array.contains(value) -> {
}
}
Nir
01/07/2021, 10:48 PMNir
01/07/2021, 10:48 PMspnda
01/07/2021, 10:54 PMwhen (value) {
in array -> {}
}
Nir
01/07/2021, 11:00 PMif (value in array)
still seems quite a bit simpler to me, but hey, whatever you like 🙂Nir
01/07/2021, 11:00 PMvalue
is coming from a complex expression another option is value.takeIf { it in array }
which can be useful depending what you're doingVampire
01/07/2021, 11:03 PMNir
01/07/2021, 11:15 PMtakeIf
in case though 🙂 But with multiple branches I'd still be inclined to if/else-if, really more because of indentation than anything else, but it's all to taste at that point