Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Just a collection of fields
- type Somename struct{
- a int
- b int
- c, d string
- }
- ...
- // Explicit instantiation
- var s = Somename{3, 4, "c", "d"}
- // Access the fields with dot notation
- s.b = 10
- // Access to fields via pointers is implicit
- p := &s
- p.c = "Pointed"
- fmt.Println(s) // {3 10 pointed d}
- // Variables can be named during instantiation
- // This allows for implicit defaults
- t := Somename{b: 17, c:"Set"}
- fmt.Println(t) // {0 17 Set }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement