Created
August 25, 2018 14:12
-
-
Save codecakes/801409fbf3c889ff61d029d03ace71ea to your computer and use it in GitHub Desktop.
if you are not returning, the implementation method type is not needed
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
| package main | |
| import "fmt" | |
| type I interface { | |
| M() // uint64 | |
| } | |
| type Vertex struct { | |
| X, Y uint64 | |
| } | |
| func (v *Vertex) M() { | |
| fmt.Println(v.X + v.Y) | |
| } | |
| func main() { | |
| var i I = &Vertex{3, 4} | |
| describe(i) | |
| i.M() | |
| } | |
| func describe(i I) { | |
| fmt.Printf("(%v, %T)\n", i, i) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment