Slide 29
Slide 29 text
sum := func(s []int, c chan int) {
sum := 0
for _, v := range s { sum += v }
c <- sum
}
!
a := [][]int{{1, 2, 3}, {4, 5, 6}}
c := make(chan int)
go sum(a[0], c)
go sum(a[1], c)
x, y := <-c, <-c
fmt.Println(x+y)
send result
to channel*
receive result
from channel
* a typed pipe through which goroutines can communicate