mirror of
https://github.com/golang/go
synced 2024-11-25 11:07:59 -07:00
spec: Allow omission of low slice bound
See also https://golang.org/cl/1957045/ R=gri, rsc, r CC=golang-dev https://golang.org/cl/2163042
This commit is contained in:
parent
e50611d235
commit
0c1695b42e
@ -2183,7 +2183,7 @@ PrimaryExpr =
|
|||||||
|
|
||||||
Selector = "." identifier .
|
Selector = "." identifier .
|
||||||
Index = "[" Expression "]" .
|
Index = "[" Expression "]" .
|
||||||
Slice = "[" Expression ":" [ Expression ] "]" .
|
Slice = "[" [ Expression ] ":" [ Expression ] "]" .
|
||||||
TypeAssertion = "." "(" Type ")" .
|
TypeAssertion = "." "(" Type ")" .
|
||||||
Call = "(" [ ExpressionList [ "," ] ] ")" .
|
Call = "(" [ ExpressionList [ "," ] ] ")" .
|
||||||
</pre>
|
</pre>
|
||||||
@ -2453,12 +2453,15 @@ s[2] == 4
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
For convenience, the <code>hi</code> expression may be omitted; the notation
|
For convenience, any of the index expressions may be omitted. A missing low
|
||||||
<code>a[lo :]</code> is shorthand for <code>a[lo : len(a)]</code>.
|
index defaults to zero; a missing high index defaults to the length of the
|
||||||
For arrays or strings, the indexes
|
array, slice, or string.
|
||||||
<code>lo</code> and <code>hi</code> must satisfy
|
</p>
|
||||||
0 <= <code>lo</code> <= <code>hi</code> <= length;
|
|
||||||
for slices, the upper bound is the capacity rather than the length.
|
<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
|
||||||
|
slices, the upper bound is the capacity rather than the length.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user