Created
August 25, 2018 14:13
-
-
Save codecakes/c3ccdd96ea82f78635ebec8d25d2ed15 to your computer and use it in GitHub Desktop.
if you are returning, an implementation type is 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() uint64 { | |
| return 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