Introduction
This challenge aims to test your ability to iterate over values received from a channel using the for
and range
syntax in Golang.
This challenge aims to test your ability to iterate over values received from a channel using the for
and range
syntax in Golang.
You are required to write a function that takes in a channel of integers and returns the sum of all the integers received from the channel.
sumInts
.chan int
.$ go run range-over-channels.go
one
two
## This example also showed that it's possible to close
## a non-empty channel but still have the remaining
## values be received.
In this challenge, you were tasked with writing a function that sums up all the integers received from a channel using the for
and range
syntax in Golang. By completing this challenge, you should have a better understanding of how to iterate over values received from a channel and how to use goroutines to receive values from a channel.