Created
June 27, 2012 18:39
-
-
Save hutch/3005930 to your computer and use it in GitHub Desktop.
Follow up to "A Rubyist has Some Difficulties with Go"
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 A struct{} | |
func (A) Name() { fmt.Println("A") } | |
func (self A) SomeAMethod() { | |
self.Name() | |
self.Name() | |
} | |
type B struct { | |
A | |
} | |
func (B) Name() { fmt.Println("B") } | |
type WithName interface { | |
Name() | |
} | |
func main() { | |
v := new(B) | |
fmt.Printf("v is %+v\n", v) | |
v.Name() | |
// These next two lines do exactly the same thing | |
v.SomeAMethod() | |
v.A.SomeAMethod() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment