A Tour of Go Range continued

You can skip the index or value by assigning to _.

If you only want the index, drop the ", value" entirely.

package main 

import "fmt"

func main() {
    pow := make([]int, 10)
    for i := range pow {
        pow[i] = i << uint(i)
    }
    for _, value := range pow {
        fmt.Printf("%d\n", value)
    }
}

 

posted @ 2014-10-27 02:27  wuhn  阅读(113)  评论(0编辑  收藏  举报