Skip to content

Commit

Permalink
Rebuild for range changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcgrana committed Dec 27, 2016
1 parent d5e30d7 commit cf6b1fe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/range/range.go
Expand Up @@ -36,7 +36,7 @@ func main() {

// `range` can also iterate over just the keys of a map.
for k := range kvs {
fmt.Println("key:", k)
fmt.Println("key:", k)
}

// `range` on strings iterates over Unicode code
Expand Down
4 changes: 2 additions & 2 deletions examples/range/range.hash
@@ -1,2 +1,2 @@
db12ad8e0baad23e5828dc5106a88323f9a7a701
g9DqcAkPVA
ebe328a57f3d34708709ca99d3304af1733592d9
SkL_AS-1Jd
21 changes: 19 additions & 2 deletions public/range
Expand Up @@ -41,7 +41,7 @@ of the data structures we&rsquo;ve already learned.</p>

</td>
<td class="code leading">
<a href="http://play.golang.org/p/g9DqcAkPVA"><img title="Run code" src="play.png" class="run" /></a>
<a href="http://play.golang.org/p/SkL_AS-1Jd"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div>

Expand Down Expand Up @@ -128,6 +128,21 @@ the indexes though.</p>
</td>
</tr>

<tr>
<td class="docs">
<p><code>range</code> can also iterate over just the keys of a map.</p>

</td>
<td class="code leading">

<div class="highlight"><pre> <span class="k">for</span> <span class="nx">k</span> <span class="o">:=</span> <span class="k">range</span> <span class="nx">kvs</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nx">Println</span><span class="p">(</span><span class="s">&quot;key:&quot;</span><span class="p">,</span> <span class="nx">k</span><span class="p">)</span>
<span class="p">}</span>
</pre></div>

</td>
</tr>

<tr>
<td class="docs">
<p><code>range</code> on strings iterates over Unicode code
Expand Down Expand Up @@ -156,11 +171,13 @@ of the <code>rune</code> and the second the <code>rune</code> itself.</p>
</td>
<td class="code">

<div class="highlight"><pre><span class="gp">$</span> go run range.go
<div class="highlight"><pre><span class="gp">$</span> go run range.go
<span class="go">sum: 9</span>
<span class="go">index: 1</span>
<span class="go">a -&gt; apple</span>
<span class="go">b -&gt; banana</span>
<span class="go">key: a</span>
<span class="go">key: b</span>
<span class="go">0 103</span>
<span class="go">1 111</span>
</pre></div>
Expand Down

0 comments on commit cf6b1fe

Please sign in to comment.