变量作用域

2020-03-29  本文已影响0人  anthonydan

import (
    "fmt"
)

func main() {
    x := 1
    fmt.Println(&x)
    if x, y := 3, 4; true {
        x = x + y
        fmt.Println(&x, x, y)
    }
    fmt.Println(&x, x)
    x , y := 5, 6
    fmt.Println(&x, x, y)
    x = x + y
    fmt.Println(&x, x, y)
}

0xc00000a0c0
0xc00000a0c8 7 4
0xc00000a0c0 1
0xc00000a0c0 5 6
0xc00000a0c0 11 6

上一篇 下一篇

猜你喜欢

热点阅读