Created
May 24, 2019 09:35
-
-
Save satoryu/362525f573f5dfafbdd6c82c9e5e273b to your computer and use it in GitHub Desktop.
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 Person struct { | |
Name string | |
} | |
func (p Person) Greeting() string { | |
return fmt.Sprintf("Hello, %v!", p.Name) | |
} | |
type Echoable func() string | |
func Echo(f Echoable) { | |
fmt.Println(f()) | |
} | |
func main() { | |
p := Person{"Satoryu"} | |
var f Echoable | |
f = p.Greeting | |
Echo(f) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment