From 0c1695b42eb51434ed2b8d9283560b7d9a7ff340 Mon Sep 17 00:00:00 2001 From: Scott Lawrence Date: Tue, 7 Sep 2010 14:30:17 -0700 Subject: [PATCH] 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 --- doc/go_spec.html | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 285c867d5f7..fb7b68c9cc9 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -2183,7 +2183,7 @@ PrimaryExpr = Selector = "." identifier . Index = "[" Expression "]" . -Slice = "[" Expression ":" [ Expression ] "]" . +Slice = "[" [ Expression ] ":" [ Expression ] "]" . TypeAssertion = "." "(" Type ")" . Call = "(" [ ExpressionList [ "," ] ] ")" . @@ -2453,12 +2453,15 @@ s[2] == 4

-For convenience, the hi expression may be omitted; the notation -a[lo :] is shorthand for a[lo : len(a)]. -For arrays or strings, the indexes -lo and hi must satisfy -0 <= lo <= hi <= length; -for slices, the upper bound is the capacity rather than the length. +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 arrays or strings, the indexes low and high must +satisfy 0 <= low <= high <= length; for +slices, the upper bound is the capacity rather than the length.