Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Range.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ for i, v := range myArray {

If only one value is used on the left of a range expression, it is the 1st value in this table.

<div style="overflow-x:auto;-webkit-overflow-scrolling:touch">

| Range expression | 1st value | 2nd value (optional) | notes |
|:-----------------|:----------|:---------------------|:------|
| array or slice a ` [n]E `, ` *[n]E `, or ` []E ` | index ` i int ` | ` a[i] ` E |
| string s string type | index ` i int ` | rune ` int ` | range iterates over Unicode code points, not bytes |
| map m ` map[K]V ` | key ` k K ` | value ` m[k] ` V |
| channel c chan E | element ` e E ` | _none_ |

</div>

## Gotchas

When iterating over a slice or map of values, one might try this:
Expand Down