diff --git a/ebook/02.7.md b/ebook/02.7.md index 2580250e..3e811460 100644 --- a/ebook/02.7.md +++ b/ebook/02.7.md @@ -68,11 +68,11 @@ channel通过操作符`<-`来接收和发送数据 import "fmt" func sum(a []int, c chan int) { - sum := 0 + total := 0 for _, v := range a { - sum += v + total += v } - c <- sum // send sum to c + c <- total // send total to c } func main() {