From: Robert Griesemer Date: Tue, 7 Sep 2010 23:32:35 +0000 (-0700) Subject: go_spec: consistent use of 'low', 'high' in slices section X-Git-Tag: weekly.2010-09-15~97 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9e5bf27acb813dd67f005d0d4a4e3bdb391a636a;p=gostls13.git 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 --- 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