mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:11:49 +08:00
add 07.2.md, 07.3.md, 07.4.md, 07.5.md
This commit is contained in:
14
eBook/examples/chapter_7/slices_forrange2.go
Normal file
14
eBook/examples/chapter_7/slices_forrange2.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
seasons := []string{"Spring", "Summer", "Autumn", "Winter"}
|
||||
for ix, season := range seasons {
|
||||
fmt.Printf("Season %d is: %s\n", ix, season)
|
||||
}
|
||||
|
||||
var season string
|
||||
for _, season = range seasons {
|
||||
fmt.Printf("%s\n", season)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user