2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-09 07:10:36 +00:00
cheat.sheets/sheets/go/Pointers

8 lines
267 B
Plaintext
Raw Normal View History

2017-05-08 20:27:00 +00:00
p := Vertex{1, 2} // p is a Vertex
q := &p // q is a pointer to a Vertex
r := &Vertex{1, 2} // r is also a pointer to a Vertex
// The type of a pointer to a Vertex is *Vertex
// new creates a pointer to a new struct instance
var s *Vertex = new(Vertex)