From 9e5bf27acb813dd67f005d0d4a4e3bdb391a636a Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 7 Sep 2010 16:32:35 -0700 Subject: [PATCH] go_spec: consistent use of 'low', 'high' in slices section Also: Added examples for slices with omitted index expressions. R=r, rsc CC=golang-dev https://golang.org/cl/2106047 --- doc/go_spec.html | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index fb7b68c9cc..d3026ca903 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -2426,14 +2426,14 @@ For a string, array, or slice a, the primary expression

-a[lo : hi]
+a[low : high]
 

-constructs a substring or slice. The index expressions lo and -hi select which elements appear in the result. The result has +constructs a substring or slice. The index expressions low and +high select which elements appear in the result. The result has indexes starting at 0 and length equal to -hi - lo. +high - low. After slicing the array a

@@ -2453,11 +2453,17 @@ s[2] == 4

-For convenience, any of the index expressions may be omitted. A missing low -index defaults to zero; a missing high index defaults to the length of the -array, slice, or string. +For convenience, any of the index expressions may be omitted. A missing low +index defaults to zero; a missing high index defaults to the length of the +sliced operand:

+
+a[2:]	// same a[2 : len(a)]
+a[:3]   // same as a[0 : 3]
+a[:]    // same as a[0 : len(a)]
+
+

For arrays or strings, the indexes low and high must satisfy 0 <= low <= high <= length; for -- 2.48.1