From 14efdea35986e47db79c8b1e8d5e57dc13e8727a Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Sun, 12 Feb 2012 09:11:44 +1100 Subject: [PATCH] effective_go: use new map deletion syntax Fixes #2984. R=golang-dev, gri CC=golang-dev https://golang.org/cl/5652071 --- doc/effective_go.html | 8 ++++---- doc/effective_go.tmpl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/effective_go.html b/doc/effective_go.html index edaffd733d1..e3e19bd392d 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 88754950733..5763cacdaba 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