RosettaCodeData/Task/Constrained-genericity/Go/constrained-genericity-4.go

23 lines
318 B
Go
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
package main
import "fmt"
type eatable interface {
eat()
}
type foodbox []eatable
type peelfirst string
func (f peelfirst) eat() {
// peel code goes here
fmt.Println("mm, that", f, "was good!")
}
func main() {
fb := foodbox{peelfirst("banana"), peelfirst("mango")}
f0 := fb[0]
f0.eat()
}