Skip to content

Instantly share code, notes, and snippets.

@montanaflynn
Created September 11, 2019 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save montanaflynn/6f04bb93f24ded3f2de59caa8628f88c to your computer and use it in GitHub Desktop.
Save montanaflynn/6f04bb93f24ded3f2de59caa8628f88c to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func CopyChange(a int) {
a = 10
}
func PointerChange(a *int) {
*a = 10
}
func main() {
x := 100
CopyChange(x)
fmt.Println(x)
// 100
PointerChange(&x)
fmt.Println(x)
// 10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment