Can I match on pairs of when values? I have a `sta...
# announcements
t
Can I match on pairs of when values? I have a
status
and a
newState
values, and I'd like to match on combinations. I could of course nest them, but I was hoping to match on a tuple like thing... e.g. when (status, newState) { 42, 13 -> "The answer is bad luck" }
n
I think you're looking for pattern matching, which Kotlin isn't the best at, compared to some languages
you might be able to use Pair to match those, but it'd end up allocating multiple objects
e.g.
when (status to newState) { Pair(42, 13) -> ... }
t
bummer, i was afraid of that. oh well
n
e
#C013CRWEG74