golang 值和指针
2018-07-15 本文已影响0人
luckyase
地址copy,引用copy
func addressCopy() {
i := 7
j := &i
i = 10
fmt.Println(i, *j)//10 10
}
值copy
func valueCopy() {
i := 7
j := i
i = 10
fmt.Println(i, j)//10 7
}
地址copy,引用copy
func addressCopy() {
i := 7
j := &i
i = 10
fmt.Println(i, *j)//10 10
}
值copy
func valueCopy() {
i := 7
j := i
i = 10
fmt.Println(i, j)//10 7
}