1
0
mirror of https://github.com/golang/go synced 2024-11-21 16:14:42 -07:00

effective_go: use new map deletion syntax

Fixes #2984.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5652071
This commit is contained in:
Rob Pike 2012-02-12 09:11:44 +11:00
parent d26c607fe6
commit 14efdea359
2 changed files with 8 additions and 8 deletions

View File

@ -1418,13 +1418,13 @@ identifier in place of the usual variable for the value.
_, present := timeZone[tz] _, present := timeZone[tz]
</pre> </pre>
<p> <p>
To delete a map entry, turn the multiple assignment around by placing To delete a map entry, use the <code>delete</code>
an extra boolean on the right; if the boolean is false, the entry built-in function, whose arguments are the map and the key to be deleted.
is deleted. It's safe to do this even if the key is already absent It's safe to do this this even if the key is already absent
from the map. from the map.
</p> </p>
<pre> <pre>
timeZone["PDT"] = 0, false // Now on Standard Time delete(timeZone, "PDT") // Now on Standard Time
</pre> </pre>
<h3 id="printing">Printing</h3> <h3 id="printing">Printing</h3>

View File

@ -1414,13 +1414,13 @@ identifier in place of the usual variable for the value.
_, present := timeZone[tz] _, present := timeZone[tz]
</pre> </pre>
<p> <p>
To delete a map entry, turn the multiple assignment around by placing To delete a map entry, use the <code>delete</code>
an extra boolean on the right; if the boolean is false, the entry built-in function, whose arguments are the map and the key to be deleted.
is deleted. It's safe to do this even if the key is already absent It's safe to do this this even if the key is already absent
from the map. from the map.
</p> </p>
<pre> <pre>
timeZone["PDT"] = 0, false // Now on Standard Time delete(timeZone, "PDT") // Now on Standard Time
</pre> </pre>
<h3 id="printing">Printing</h3> <h3 id="printing">Printing</h3>