November 2017
Intermediate to advanced
670 pages
17h 35m
English
In the itertools.go file, we see that the iterator uses Go channels to range over each element in the collection:
type Iter chan interface{}func New(els ... interface{}) Iter { c := make(Iter) go func () { for _, el := range els { c <- el } close(c) }() return c}
The New function can be used as follows to take a list of values and turn it into a new iterable collection:
New(3,5,6)