diff --git a/doc/go_spec.html b/doc/go_spec.html index 941a2055f4..cbcaf3a338 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -1644,8 +1644,10 @@ built-in function len 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. +delete and +clear built-in function.

+

A new, empty map value is made using the built-in function make, @@ -2316,7 +2318,7 @@ Zero value: nil Functions: - append cap close complex copy delete imag len + append cap clear close complex copy delete imag len make new panic print println real recover @@ -7181,6 +7183,36 @@ so they can only appear in call expressions; they cannot be used as function values.

+

Clear

+ +

+The built-in function clear takes an argument of map, +slice, or type parameter type, +and deletes or zeroes out all elements. +

+ +
+Call        Argument type     Result
+
+clear(m)    map[K]T           deletes all entries, resulting in an
+                              empty map (len(m) == 0)
+
+clear(s)    []T               sets all elements up to the length of
+                              s to the zero value of T
+
+clear(t)    type parameter    see below
+
+ +

+If the argument type is a type parameter, +all types in its type set must be maps or slices, and clear +performs the operation corresponding to the actual type argument. +

+ +

+If the map or slice is nil, clear is a no-op. +

+

Close