summaryrefslogtreecommitdiff
path: root/src/builtin
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2023-01-21 02:36:45 +0700
committerGopher Robot <gobot@golang.org>2023-02-01 15:21:00 +0000
commit4fe46cee4ea4eb15e38675ff32222f07e6b15404 (patch)
treeb328250e7cafaf28374474e3138f23f022a0c599 /src/builtin
parent56a14ad4bc19d5ee9d4257f370a570377e81e544 (diff)
downloadgo-git-4fe46cee4ea4eb15e38675ff32222f07e6b15404.tar.gz
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 <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/builtin')
-rw-r--r--src/builtin/builtin.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/builtin/builtin.go b/src/builtin/builtin.go
index d3637584fe..bcfb7ce956 100644
--- a/src/builtin/builtin.go
+++ b/src/builtin/builtin.go
@@ -227,6 +227,15 @@ func real(c ComplexType) FloatType
// the type of c.
func imag(c ComplexType) FloatType
+// The clear built-in function clears maps and slices.
+// For maps, clear deletes all entries, resulting in an empty map.
+// For slices, clear sets all elements up to the length of the slice
+// to the zero value of the respective element type. If the argument
+// type is a type parameter, the type parameter's type set must
+// contain only map or slice types, and clear performs the operation
+// implied by the type argument.
+func clear[T ~[]Type | ~map[Type]Type1](t T)
+
// The close built-in function closes a channel, which must be either
// bidirectional or send-only. It should be executed only by the sender,
// never the receiver, and has the effect of shutting down the channel after