The problem of multiple assignment of go

package main

import ("fmt")

func fibonacci() func(int) int {
    pre_pre, pre := 1, 1;
    return func(x int) int {
        if x == 0 || x == 1 {
            return pre
        } else {
            tmp := pre_pre + pre

            //
            //pre_pre = pre
            //pre = tmp

            //
            //pre_pre, pre = pre, tmp

            //
            pre, pre_pre = tmp, pre

            return tmp
        }
    } 
}

func main() {
    f := fibonacci()
    for i := 0; i < 10; iPP {
        fmt.Println(f(i))
    }
}

I use iterations to output Fibonacci sequences, and I use three methods for the two leading numbers in the iterative series: the first in the
comments, and the most common. The second and third of the
comments use the multiple assignment features of go.
the key is that the second and third kinds can output the sequence correctly .
I wonder, what is the order in which this multiple assignment is performed? How does it correctly parse my assignment steps (that is, the steps in the first one)?

Mar.23,2021

executes from left to right, but the variable assigned on the left does not take effect until the next line of the expression.

means a, b = b, axi1 can be understood as

.
temp_a = a
a = b
b = temp_a + 1

more examples https://golang.org/ref/spec-sharpA.

a, b = b, a  // exchange a and b

x := []int{1, 2, 3}
i := 0
i, x[i] = 1, 2  // set i = 1, x[0] = 2

i = 0
x[i], i = 2, 1  // set x[0] = 2, i = 1

x[0], x[0] = 1, 2  // set x[0] = 1, then x[0] = 2 (so x[0] == 2 at end)

x[1], x[3] = 4, 5  // set x[1] = 4, then panic setting x[3] = 5.

type Point struct { x, y int }
var p *Point
x[2], p.x = 6, 7  // set x[2] = 6, then panic setting p.x = 7

i = 2
x = []int{3, 5, 7}
for i, x[i] = range x {  // set i, x[2] = 0, x[0]
    break
}
// after this loop, i == 0 and x == []int{3, 5, 3}

The

specification requires that the expression on the right of the assignment statement be evaluated first.

so

//  tem = 3, pre = 2
pre, pre_pre = 3, 2
Menu