The range
form of the for
loop iterates over a slice or map.
package mainimport "fmt"var pow = []int{ 1, 2, 4, 8, 16, 32, 64, 128}func main() { for i, v := range pow { fmt.Printf("2**%d = %d\n", i, v) }}
本文共 268 字,大约阅读时间需要 1 分钟。
The range
form of the for
loop iterates over a slice or map.
package mainimport "fmt"var pow = []int{ 1, 2, 4, 8, 16, 32, 64, 128}func main() { for i, v := range pow { fmt.Printf("2**%d = %d\n", i, v) }}
转载于:https://www.cnblogs.com/ghgyj/p/4053332.html