Last active
December 23, 2015 14:09
-
-
Save pzurek/6646652 to your computer and use it in GitHub Desktop.
Pointers in Go. Short tale of asterisk and ampersand.
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 main() { | |
var a int | |
var b int | |
var c *int | |
a = 42 | |
b = a | |
c = &a | |
fmt.Printf("Values:\n a = %v\n b = %v\n c = %v\n*c = %v\n", a, b, c, *c) | |
a = 21 | |
fmt.Printf("Values:\n a = %v\n b = %v\n c = %v\n*c = %v\n", a, b, c, *c) | |
fmt.Printf("Types:\n a: %T\n b: %T\n c: %T\n*c: %T\n", a, b, c, *c) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment