Last active
January 22, 2019 23:55
-
-
Save chardos/4472e9c0c7df6811cfba687c192c9835 to your computer and use it in GitHub Desktop.
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 | |
import "fmt" | |
func main() { | |
a := 10 | |
b := &a // &a is the reference of a | |
c := a | |
fmt.Println(a, b, *b, c) // *b means the value this reference is pointing to (dereference the value) | |
// 10 0xc0000160a0 10 10 | |
a = 20 | |
fmt.Println(a, b, *b, c) | |
*b = 30 | |
fmt.Println(a, b, *b, c) | |
// 30 0xc0000160a0 30 10 | |
c = 40 | |
fmt.Println(a, b, *b, c) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment