]> Cypherpunks repositories - gostls13.git/commitdiff
effective_go: use new map deletion syntax
authorRob Pike <r@golang.org>
Sat, 11 Feb 2012 22:11:44 +0000 (09:11 +1100)
committerRob Pike <r@golang.org>
Sat, 11 Feb 2012 22:11:44 +0000 (09:11 +1100)
Fixes #2984.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5652071

doc/effective_go.html
doc/effective_go.tmpl

index edaffd733d1a9956039b533079b66237cfdc89e6..e3e19bd392dc26c393a787605e86f527a1f2590f 100644 (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>
index 88754950733f8ebaa819fad900c6e5aa91d40f0e..5763cacdabafb892d422e2b4531b684f212ed97e 100644 (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>