Created
June 18, 2016 05:48
-
-
Save narenaryan/d5365f1d2c25c4dda7f02504d9abf4c9 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" | |
| ) | |
| type Point struct{ | |
| x int | |
| y int | |
| } | |
| func main() { | |
| p := Point{1,2} | |
| p.y = 23 | |
| z := &p | |
| fmt.Println(p) | |
| fmt.Println(z.y) | |
| alterPoint(z) | |
| fmt.Println(p) | |
| alterPoint(&p) | |
| fmt.Println(p) | |
| } | |
| func alterPoint(p *Point) { | |
| p.y = p.y + 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment