diff --git a/doc/go_spec.html b/doc/go_spec.html index 810df2c46a..4c1ecef353 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1159,9 +1159,10 @@ map [string] interface {} The number of map elements is called its length. For a map m, it can be discovered using the built-in function len(m) -and may change during execution. Elements may be added and removed -during execution using special forms of assignment; -and they may be accessed with index expressions. +and may change during execution. Elements may be added during execution +using assignments and retrieved with +index expressions; they may be removed with the +delete built-in function.

A new, empty map value is made using the built-in @@ -2431,21 +2432,6 @@ where the result of the index expression is a pair of values with types a[x] as in the single-result form.

-

-Similarly, if an assignment to a map element has the special form -

- -
-a[x] = v, ok
-
- -

-and boolean ok has the value false, -the entry for key x is deleted from the map; if -ok is true, the construct acts like -a regular assignment to an element of the map. -

-

Assigning to an element of a nil map causes a run-time panic. @@ -4738,6 +4724,27 @@ n2 := copy(s, s[2:]) // n2 == 4, s == []int{2, 3, 4, 5, 4, 5} n3 := copy(b, "Hello, World!") // n3 == 5, b == []byte("Hello") + +

Deletion of map elements

+ +

+The built-in function delete removes the element with key +k from a map m. The +type of k must be assignable +to the key type of m. +

+ +
+delete(m, k)  // remove element m[k] from map m
+
+ +

+If the element m[k] does not exist, delete is +a no-op. Calling delete with a nil map causes a +run-time panic. +

+ +

Assembling and disassembling complex numbers