// Chapter 22 example: creating a slice and looping over it. // Run with: go run exercises/22/01-slice-loop.go package main import "fmt" func main() { fruits := []string{"apple", "banana", "cherry"} fmt.Println(fruits[0]) fmt.Println(fruits[1]) fmt.Println(fruits[2]) fmt.Println("Length:", len(fruits)) for i, fruit := range fruits { fmt.Printf("%d. %s\n", i+1, fruit) } // Try this: add a fourth fruit and watch the length grow. }