Last active
June 6, 2019 23:20
-
-
Save trumae/4ace93a48ba6356e9feab02a20e1a759 to your computer and use it in GitHub Desktop.
Golang - ponteiros que trocam de valor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func main() { | |
var x [10]int | |
var y = &x[2] //ref to array contetn | |
var z = y // ref copy | |
println(&x, y, z) | |
a(x) | |
println(&x, y, z) | |
} | |
//go:noinline | |
func a(x [10]int) { | |
println(`func a`) | |
var y [100]int | |
b(y) | |
} | |
//go:noinline | |
func b(x [100]int) { | |
println(`func b`) | |
var y [1000]int | |
c(y) | |
} | |
//go:noinline | |
func c(x [1000]int) { | |
println(`func c`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment