mirror of
https://github.com/golang/go
synced 2024-11-21 22:24:40 -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:
parent
d26c607fe6
commit
14efdea359
@ -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>
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user