Could you show a use case where this type of destructuring is clearly needed?
Yes, there is a real-world example. This pain happens with RxKotlin when using withLatestFrom
method:
import io.reactivex.rxjava3.kotlin.withLatestFrom
streamOfPairs.withLatestFrom(streamOfValues).subscribe { (pair, z) ->
val (x, y) = pair
// ....
},
When we attach an additional stream to the original stream of pairs, we end up with a nested pair that cannot be simply deconstructed anymore.