diff options
author | Robert Griesemer <gri@golang.org> | 2010-09-07 16:32:35 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2010-09-07 16:32:35 -0700 |
commit | e664bcd2fa71e9a106e1dd526920cf2bb9be46a5 (patch) | |
tree | 66b4bead4d17e71c924f7ebd4576368d988c47d0 /doc | |
parent | ce988ac3322490101287dc1f766e9129fa7edb05 (diff) | |
download | go-e664bcd2fa71e9a106e1dd526920cf2bb9be46a5.tar.gz |
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
http://codereview.appspot.com/2106047
Diffstat (limited to 'doc')
-rw-r--r-- | doc/go_spec.html | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html index fb7b68c9c..d3026ca90 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -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> - <code>lo</code>. +<code>high</code> - <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 <= <code>low</code> <= <code>high</code> <= length; for |