add example for ranging through keys
This commit is contained in:
parent
513eefcddc
commit
394e8aa27e
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user