Last active
August 29, 2015 13:56
-
-
Save javouhey/9225372 to your computer and use it in GitHub Desktop.
#golang object creation
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
| type Stack struct { | |
| a int | |
| b string | |
| } | |
| func main() { | |
| t := Stack{} | |
| s := Stack{b: "a"} | |
| t := Stack{1, "a"} | |
| t := Stack{a: 42} | |
| } | |
| // http://areyoufuckingcoding.me/2012/07/25/object-desoriented-language/ | |
| type Person struct { Name string } | |
| type Woman struct { Person } | |
| func main() { | |
| w := Woman{Person: Person{Name: "laetitia"}} | |
| fmt.Println("hello", w, w.Name) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment