1
0
mirror of https://github.com/golang/go synced 2024-11-21 15:34:45 -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]
</pre>
<p>
To delete a map entry, turn the multiple assignment around by placing
an extra boolean on the right; if the boolean is false, the entry
is deleted. It's safe to do this even if the key is already absent
To delete a map entry, use the <code>delete</code>
built-in function, whose arguments are the map and the key to be deleted.
It's safe to do this this even if the key is already absent
from the map.
</p>
<pre>
timeZone["PDT"] = 0, false // Now on Standard Time
delete(timeZone, "PDT") // Now on Standard Time
</pre>
<h3 id="printing">Printing</h3>

View File

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