Slide 73
Slide 73 text
func main() {
functions := make(chan func(int, int)(int))
go executor(functions)
!
functions <- add
functions <- multiply
functions <- subtract
}
!
func add(x, y int) int {
return x + y
}
!
func multiply(x, y int) int {
return x * y
}
!
func subtract(x, y int) int {
return x - y
}
!
func executor(functions chan func(int, int)(int)) {
for f := range functions {
fmt.Println("The result is: ", f(10, 10))
}
}