Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
type eatable interface {
|
||||
eat()
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
type foodbox []eatable
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
type peelfirst string
|
||||
|
||||
func (f peelfirst) eat() {
|
||||
// peel code goes here
|
||||
fmt.Println("mm, that", f, "was good!")
|
||||
}
|
||||
22
Task/Constrained-genericity/Go/constrained-genericity-4.go
Normal file
22
Task/Constrained-genericity/Go/constrained-genericity-4.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue