mirror of
https://github.com/golang/go.git
synced 2026-04-01 17:07:17 +09:00
builtin: incorporate all feedback into doc string for new
The previously submitted CL didn't include some of the feedback that was provided on the CL. Specifically, it didn't mention the behavior of `new` for untyped constant arguments. For #77584. Change-Id: I1668a79a655246e5a55a4741a6c564b7dd6707c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/749061 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
committed by
Damien Neil
parent
0886e65b11
commit
5c7d8a3e48
@@ -224,15 +224,14 @@ func max[T cmp.Ordered](x T, y ...T) T
|
||||
// min will return NaN.
|
||||
func min[T cmp.Ordered](x T, y ...T) T
|
||||
|
||||
// The built-in function new creates a new, initialized variable and returns
|
||||
// The built-in function new allocates a new, initialized variable and returns
|
||||
// a pointer to it. It accepts a single argument, which may be either a type
|
||||
// or an expression.
|
||||
//
|
||||
// If the argument is a type T, then new(T) allocates a variable of type T
|
||||
// initialized to its zero value.
|
||||
//
|
||||
// If the argument is an expression x, then new(x) allocates a variable of
|
||||
// the type of x initialized to the value of x.
|
||||
// Otherwise, the argument is an expression x and new(x) allocates a variable
|
||||
// of the type of x initialized to the value of x. If that value is an untyped
|
||||
// constant, it is first implicitly converted to its default type.
|
||||
func new(TypeOrExpr) *Type
|
||||
|
||||
// The complex built-in function constructs a complex value from two
|
||||
|
||||
Reference in New Issue
Block a user