Created
March 4, 2020 01:44
-
-
Save iansmith/62f8c52c81b2a86b2710d59953f66dbe 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 "somedwarf" | |
import "fmt" | |
type Sleepy struct {} | |
type IsHappy interface { | |
Happy() bool | |
} | |
func (s Sleepy) Happy() bool { | |
return true | |
} | |
func main() { | |
g:=somedwarf.Grumpy{} | |
s:=Sleepy{} | |
PrintHappy(g) | |
PrintHappy(s) | |
} | |
func PrintHappy(h IsHappy) { | |
if h.Happy() { | |
fmt.Printf("dwarf is happy\n") | |
} else { | |
fmt.Printf("dwarf is sad\n") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment