Merge commit '563046f4c84545b0558830fa533c17858a09c964' into ja
This commit is contained in:
@@ -68,11 +68,11 @@ channel通过操作符`<-`来接收和发送数据
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func sum(a []int, c chan int) {
|
func sum(a []int, c chan int) {
|
||||||
sum := 0
|
total := 0
|
||||||
for _, v := range a {
|
for _, v := range a {
|
||||||
sum += v
|
total += v
|
||||||
}
|
}
|
||||||
c <- sum // send sum to c
|
c <- total // send total to c
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user