Created
November 9, 2015 15:29
-
-
Save j16r/0cb202da1d78bce8271f to your computer and use it in GitHub Desktop.
An array of traits?
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 Trait interface { | |
String() string | |
} | |
type Traitable struct { | |
} | |
func (t Traitable) String() string { | |
return "me!" | |
} | |
func main() { | |
traitables := []Trait{ | |
Traitable{}, | |
} | |
for _, t := range traitables { | |
fmt.Println(t.String()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This outputs: