Merge remote-tracking branch 'mathonsunday/master'

This commit is contained in:
Mark McGranaghan 2015-01-10 14:54:20 -08:00
commit 310c3f641d
6 changed files with 16 additions and 11 deletions

View File

@ -37,7 +37,8 @@ func main() {
// value from a map indicates if the key was present // value from a map indicates if the key was present
// in the map. This can be used to disambiguate // in the map. This can be used to disambiguate
// between missing keys and keys with zero values // between missing keys and keys with zero values
// like `0` or `""`. // like `0` or `""`. Here we didn't the value itself, so
// we ignored it with the _blank identifier_ `_`.
_, prs := m["k2"] _, prs := m["k2"]
fmt.Println("prs:", prs) fmt.Println("prs:", prs)

View File

@ -1,2 +1,2 @@
572365c80895f32241032397bd69094886892d90 ee96724fc32ee253ba2a5390d66d6880d7fdd28f
D-F9YN_V8r Z2ORjMdW_u

View File

@ -20,7 +20,7 @@ func main() {
// `range` on arrays and slices provides both the // `range` on arrays and slices provides both the
// index and value for each entry. Above we didn't // index and value for each entry. Above we didn't
// need the index, so we ignored it with the // need the index, so we ignored it with the
// _blank identifier_ `_`. Sometimes we actually want // blank identifier `_`. Sometimes we actually want
// the indexes though. // the indexes though.
for i, num := range nums { for i, num := range nums {
if num == 3 { if num == 3 {

View File

@ -1,2 +1,2 @@
e6458150862a6b26e95629ba6a90a6a3036d7d52 67d7882d364517608741e4045aa10ba489b37987
Ys3V-ohVRy u2yg3m1eFT

View File

@ -40,7 +40,7 @@
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/D-F9YN_V8r"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/Z2ORjMdW_u"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -159,11 +159,15 @@ a map.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The optional second return value when getting a <p> Above we didn&rsquo;t
need the index, so we ignored it with the
<em>blank identifier</em> <code>_</code>.
The optional second return value when getting a
value from a map indicates if the key was present value from a map indicates if the key was present
in the map. This can be used to disambiguate in the map. This can be used to disambiguate
between missing keys and keys with zero values between missing keys and keys with zero values
like <code>0</code> or <code>&quot;&quot;</code>.</p> like <code>0</code> or <code>&quot;&quot;</code>. Here we didn&rsquo;t the value itself, so
we ignored it with the <em>blank identifier</em> <code>_</code>.</p>
</td> </td>
<td class="code leading"> <td class="code leading">

View File

@ -41,7 +41,7 @@ of the data structures we&rsquo;ve already learned.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/Ys3V-ohVRy"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/u2yg3m1eFT"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -96,7 +96,7 @@ Arrays work like this too.</p>
<p><code>range</code> on arrays and slices provides both the <p><code>range</code> on arrays and slices provides both the
index and value for each entry. Above we didn&rsquo;t index and value for each entry. Above we didn&rsquo;t
need the index, so we ignored it with the need the index, so we ignored it with the
<em>blank identifier</em> <code>_</code>. Sometimes we actually want blank identifier <code>_</code>. Sometimes we actually want
the indexes though.</p> the indexes though.</p>
</td> </td>