]> Cypherpunks.ru repositories - gostls13.git/commitdiff
doc: clarify non-nil zero length slice to array pointer conversion
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 24 Jul 2021 11:34:16 +0000 (18:34 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 26 Jul 2021 17:47:47 +0000 (17:47 +0000)
There is an example for nil slice already, so adding example for non-nil
zero length slice, too, clarifying to the reader that the result is also
non-nil and different from nil slice case.

Updates #395

Change-Id: I019db1b1a1c0c621161ecaaacab5a4d888764b1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/336890
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
doc/go_spec.html

index cc7ed6a5618520583ad3c85c73e617383d99d241..0e14a1f3b63188cbb945f22ad8896eb0f9b35268 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of Jul 24, 2021",
+       "Subtitle": "Version of Jul 26, 2021",
        "Path": "/ref/spec"
 }-->
 
@@ -4335,6 +4335,9 @@ s4 := (*[4]byte)(s)      // panics: len([4]byte) > len(s)
 var t []string
 t0 := (*[0]string)(t)    // t0 == nil
 t1 := (*[1]string)(t)    // panics: len([1]string) > len(t)
+
+u := make([]byte, 0)
+u0 = (*[0]byte)(u)       // u0 != nil
 </pre>
 
 <h3 id="Constant_expressions">Constant expressions</h3>