Created
February 13, 2021 19:49
-
-
Save madflojo/ebf22ea59b3f368d18b6f6736cbf1d02 to your computer and use it in GitHub Desktop.
Interface Article - Speaking English
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 Speak interface { | |
SayHello() string | |
} | |
type English struct{} | |
func (e English) SayHello() string { | |
return "Hello" | |
} | |
func main() { | |
var voice Speak | |
// Say Hello in English | |
voice = English{} | |
fmt.Println(voice.SayHello()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment