External iterators

External iterators are used in order to access elements within an object and point to the next element in the object (known as element access and traversal, respectively). Go uses the for loop iterator heavily. The for loop is Go's only natural looping construct, and greatly simplifies program construction. A for loop is as simple as the following:

package main

import "fmt"

func main() {
for i := 0; i < 5; i++ {
fmt.Println("Hi Gophers!")
}
}

We can see our output as follows:

Our for loop iterator is simple, but it proves a strong point—sometimes, simplicity works as expected for difficult problem sets.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.214.155