Created
October 6, 2012 21:41
-
-
Save benevolent0505/3846251 to your computer and use it in GitHub Desktop.
「A Tour of Go」でGo言語を学ぶ(~#28) ref: http://qiita.com/items/ddaa13be965e15185dad
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
4 |
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
{1 2} &{1 2} {1 0} {0 0} |
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 Vertex struct { | |
X int | |
Y int | |
} | |
func main() { | |
v := Vertex{1, 2} | |
v.X = 4 | |
fmt.Println(v.X) | |
} |
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 Vertex struct { | |
X, Y int | |
} | |
var ( | |
p = Vertex{1, 2} // has type Vertex | |
q = &Vertex{1, 2} // has type *Vertex | |
r = Vertex{X: 1} // Y:0 is implicit | |
s = Vertex{} // X:0 and Y:0 | |
) | |
func main() { | |
fmt.Println(p, q, r, s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment