add example for ranging through keys

This commit is contained in:
Jim Walker 2016-03-07 15:45:32 -05:00 committed by Mark McGranaghan
parent 513eefcddc
commit 394e8aa27e

View File

@ -34,6 +34,11 @@ func main() {
fmt.Printf("%s -> %s\n", k, v)
}
// `range` can also iterate over just the keys of a map.
for k := range kvs {
fmt.Println("key:", k)
}
// `range` on strings iterates over Unicode code
// points. The first value is the starting byte index
// of the `rune` and the second the `rune` itself.