]> Cypherpunks repositories - gostls13.git/commitdiff
go_spec: consistent use of 'low', 'high' in slices section
authorRobert Griesemer <gri@golang.org>
Tue, 7 Sep 2010 23:32:35 +0000 (16:32 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 7 Sep 2010 23:32:35 +0000 (16:32 -0700)
Also: Added examples for slices with omitted index expressions.

R=r, rsc
CC=golang-dev
https://golang.org/cl/2106047

doc/go_spec.html

index fb7b68c9cc9ec4174445cdceb644f7ce3f8a70b7..d3026ca903509c21db862fc59d1e8d485c6f0dbf 100644 (file)
@@ -2426,14 +2426,14 @@ For a string, array, or slice <code>a</code>, the primary expression
 </p>
 
 <pre>
-a[lo : hi]
+a[low : high]
 </pre>
 
 <p>
-constructs a substring or slice. The index expressions <code>lo</code> and
-<code>hi</code> select which elements appear in the result. The result has
+constructs a substring or slice. The index expressions <code>low</code> and
+<code>high</code> select which elements appear in the result. The result has
 indexes starting at 0 and length equal to
-<code>hi</code>&nbsp;-&nbsp;<code>lo</code>.
+<code>high</code>&nbsp;-&nbsp;<code>low</code>.
 After slicing the array <code>a</code>
 </p>
 
@@ -2453,11 +2453,17 @@ s[2] == 4
 </pre>
 
 <p>
-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 <code>low</code>
+index defaults to zero; a missing <code>high</code> index defaults to the length of the
+sliced operand:
 </p>
 
+<pre>
+a[2:]  // same a[2 : len(a)]
+a[:3]   // same as a[0 : 3]
+a[:]    // same as a[0 : len(a)]
+</pre>
+
 <p>
 For arrays or strings, the indexes <code>low</code> and <code>high</code> must
 satisfy 0 &lt;= <code>low</code> &lt;= <code>high</code> &lt;= length; for