2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-17 09:25:32 +00:00
cheat.sheets/sheets/_go/Pointers

8 lines
266 B
Plaintext
Raw Normal View History

2017-05-28 21:17:32 +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)