Created
September 11, 2019 06:12
-
-
Save montanaflynn/6f04bb93f24ded3f2de59caa8628f88c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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