Skip to content

Commit 4fe46ce

Browse files
cuonglmgopherbot
authored andcommitted
builtin: add documentation for clear
Updates #56351 Change-Id: I7b1dd29e60f71d804a6d9cba3377e28c3a5b964e Reviewed-on: https://go-review.googlesource.com/c/go/+/462935 Auto-Submit: Cuong Manh Le <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Rob Pike <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 56a14ad commit 4fe46ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/builtin/builtin.go

+9
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ func real(c ComplexType) FloatType
227227
// the type of c.
228228
func imag(c ComplexType) FloatType
229229

230+
// The clear built-in function clears maps and slices.
231+
// For maps, clear deletes all entries, resulting in an empty map.
232+
// For slices, clear sets all elements up to the length of the slice
233+
// to the zero value of the respective element type. If the argument
234+
// type is a type parameter, the type parameter's type set must
235+
// contain only map or slice types, and clear performs the operation
236+
// implied by the type argument.
237+
func clear[T ~[]Type | ~map[Type]Type1](t T)
238+
230239
// The close built-in function closes a channel, which must be either
231240
// bidirectional or send-only. It should be executed only by the sender,
232241
// never the receiver, and has the effect of shutting down the channel after

0 commit comments

Comments
 (0)