for loop on values of slice (no index)
package main
import "fmt"
func main() {
dwarfs := []string{"Doc", "Grumpy", "Happy", "Sleepy", "Bashful", "Sneezy", "Dopey"}
for _, name := range dwarfs {
fmt.Println(name)
}
}
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
package main
import "fmt"
func main() {
dwarfs := []string{"Doc", "Grumpy", "Happy", "Sleepy", "Bashful", "Sneezy", "Dopey"}
for _, name := range dwarfs {
fmt.Println(name)
}
}