From: Rob Pike Date: Sat, 11 Feb 2012 22:11:44 +0000 (+1100) Subject: effective_go: use new map deletion syntax X-Git-Tag: weekly.2012-02-14~115 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=14efdea35986e47db79c8b1e8d5e57dc13e8727a;p=gostls13.git effective_go: use new map deletion syntax Fixes #2984. R=golang-dev, gri CC=golang-dev https://golang.org/cl/5652071 --- diff --git a/doc/effective_go.html b/doc/effective_go.html index edaffd733d..e3e19bd392 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -1418,13 +1418,13 @@ identifier in place of the usual variable for the value. _, present := timeZone[tz]

-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 delete +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.

-timeZone["PDT"] = 0, false  // Now on Standard Time
+delete(timeZone, "PDT")  // Now on Standard Time
 

Printing

diff --git a/doc/effective_go.tmpl b/doc/effective_go.tmpl index 8875495073..5763cacdab 100644 --- a/doc/effective_go.tmpl +++ b/doc/effective_go.tmpl @@ -1414,13 +1414,13 @@ identifier in place of the usual variable for the value. _, present := timeZone[tz]

-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 delete +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.

-timeZone["PDT"] = 0, false  // Now on Standard Time
+delete(timeZone, "PDT")  // Now on Standard Time
 

Printing