You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func main() {
l := []int{1, 2, 3}
for i, v := range l {
println(&i, &v)
}
}
result is:
0xc00004c718 0xc00004c710
0xc00004c718 0xc00004c710
0xc00004c718 0xc00004c710
func main() {
l := []int{1, 2, 3}
for i, v := range l {
fmt.Println(&i, &v)
}
}
result is:
0xc000096010 0xc000096008
0xc000096030 0xc000096018
0xc000096040 0xc000096038
func main() {
l := []int{1, 2, 3}
for i, v := range l {
println(&i, &v)
fmt.Println(&i, &v)
}
}
result is:
0xc0000120a0 0xc000012098
0xc0000120a0 0xc000012098
0xc0000120c0 0xc0000120a8
0xc0000120c0 0xc0000120a8
0xc0000120d0 0xc0000120c8
0xc0000120d0 0xc0000120c8
What did you see happen?
result is different between with println(&i, &v) & fmt.Println(&i, &v)
Go version
go1.22.1
Output of
go env
in your module/workspace:What did you do?
What did you see happen?
result is different between with println(&i, &v) & fmt.Println(&i, &v)
What did you expect to see?
0xc000096010 0xc000096008
0xc000096030 0xc000096018
0xc000096040 0xc000096038
The text was updated successfully, but these errors were encountered: