]> Cypherpunks repositories - gostls13.git/commitdiff
spec: describe an edge case for slice expression of nil slice
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 14 Sep 2022 04:51:59 +0000 (11:51 +0700)
committerGopher Robot <gobot@golang.org>
Wed, 21 Sep 2022 14:06:17 +0000 (14:06 +0000)
Change-Id: I8c0e2b37e7e8cb4db6ad0b456fde7eb908ffbd04
Reviewed-on: https://go-review.googlesource.com/c/go/+/430836
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

doc/go_spec.html

index e2163b466d82955748a9f0e6a46d75cd16cb0e3f..c188cd4c1f205a863d531b7758a52a9ac73e1fad 100644 (file)
@@ -3934,6 +3934,9 @@ var a [10]int
 s1 := a[3:7]   // underlying array of s1 is array a; &amp;s1[2] == &amp;a[5]
 s2 := s1[1:4]  // underlying array of s2 is underlying array of s1 which is array a; &amp;s2[1] == &amp;a[5]
 s2[1] = 42     // s2[1] == s1[2] == a[5] == 42; they all refer to the same underlying array element
+
+var s []int
+s3 := s[:0]    // s3 == nil
 </pre>