Why not destructuring assignment?

Given there is destructuring declaration, why not destructing assignment?
Sample use case:

fun localFibonacci(n:Int) = buildSequence{
    var (a, b) = Pair(0,1)  // can use destructing here
    while(a < n) {
        yield(a)
        //  (a, b) = Pair(b, a+b)  // so why not here when it very useful

        val (tempa, tempb) = Pair(b, a+b)  // need to do these three lines in place of the one above 
        a = tempa  // only because needed temporary values 
        b = tempb  // even a third line needed when one should suffice
    }
}
// sample call 
println("fib is ${localFibonacci(50).toList()}")

Surely this would be simple to add, and fits with the idiom of being pragmatic?

1 Like

you can vote for it overhere:

https://youtrack.jetbrains.com/issue/KT-11362

1 Like

Thank you for that…even an example there with fibonacci already - hopefully though this thread may draw some extra attention and perhaps some extra votes.

As you suggested, I voted :slight_smile: Took me a few moments to find the icon next to ‘voters’ in order to register a vote as it appeared to be greyed out.

1 Like