Created
March 27, 2018 17:19
-
-
Save jim/26c2d2bf4c405068df4b881e97175d45 to your computer and use it in GitHub Desktop.
nil struct fields
This file contains 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 Bread struct { | |
name string | |
} | |
type Cheese struct { | |
milk string | |
} | |
type Sandwich struct { | |
bread *Bread | |
cheese *Cheese | |
} | |
func main() { | |
rye := Bread{name: "Tye"} | |
sando := Sandwich{ | |
bread: &rye, | |
} | |
fmt.Printf("%#v", sando) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment