美文网首页Go
Go array range 02

Go array range 02

作者: JaedenKil | 来源:发表于2019-03-08 15:14 被阅读0次
package main

import "fmt"

func main() {
    pow := make([]int, 10)
    for index := range pow { // Drop ", value" totally, only cares about index
        fmt.Println(index)
    }
    fmt.Println("------") // Ignore index, cares about value
    for _, value := range pow {
        fmt.Printf("%d\n", value)
    }
}
0
1
2
3
4
5
6
7
8
9
------
0
0
0
0
0
0
0
0
0
0

相关文章

网友评论

    本文标题:Go array range 02

    本文链接:https://www.haomeiwen.com/subject/hzmrpqtx.html