To not create temprorary objects, I propose following syntax:
when (obj) {
is Pair<*, *> -> when((k, v) *obj) {
(1, "5") -> ... // k, v available here
("asdfa", true) -> ...
(variable, _) -> ...
}
}
if ((k, v) *obj == ("asdfa", 42) {
// k, v available here
}
and would be nice to see matched value as it
when (obj) {
is Pair<*, *> -> when((k, v) *obj) {
(1, "5") -> it::run { println("[$key=$value]") }
}
}
with => arrow to make it available as this
(1, "adfa") => println("[$key=$value]")