From 9c9e811bb34dc48abf256aae91af9199fb9f0f71 Mon Sep 17 00:00:00 2001
From: Robert Griesemer string
.
The length of a string s
(its size in bytes) can be discovered using
the built-in function len
.
The length is a compile-time constant if the string is a constant.
-A string's bytes can be accessed by integer indices 0 through
-len(s)-1
(§Indexes).
+A string's bytes can be accessed by integer indices
+0 through len(s)-1
.
It is illegal to take the address of such an element; if
s[i]
is the i
'th byte of a
string, &s[i]
is invalid.
@@ -819,8 +819,8 @@ The length is part of the array's type and must be a
constant expression that evaluates to a non-negative
integer value. The length of array a
can be discovered
using the built-in function len
.
-The elements can be indexed by integer
-indices 0 through len(a)-1
(§Indexes).
+The elements can be addressed by integer indices
+indices 0 through len(a)-1
.
Array types are always one-dimensional but may be composed to form
multi-dimensional types.
s
can be discovered by the built-in function
len
; unlike with arrays it may change during
-execution. The elements can be addressed by integer indices 0
-through len(s)-1
(§Indexes). The slice index of a
+execution. The elements can be addressed by integer indices
+0 through len(s)-1
. The slice index of a
given element may be less than the index of the same element in the
underlying array.
@@ -1257,7 +1257,7 @@ For a map m
, it can be discovered using the
built-in function len
and may change during execution. Elements may be added during execution
using assignments and retrieved with
-index expressions; they may be removed with the
+index expressions; they may be removed with the
delete
built-in function.
@@ -2120,7 +2120,7 @@ The types of the expressions must be assignable to the respective field, element, and key types of the LiteralType; there is no additional conversion. The key is interpreted as a field name for struct literals, -an index expression for array and slice literals, and a key for map literals. +an index for array and slice literals, and a key for map literals. For map literals, all elements must have a key. It is an error to specify multiple elements with the same field name or constant key value. @@ -2480,7 +2480,7 @@ TODO: Specify what happens to receivers. --> -
A primary expression of the form @@ -2596,7 +2596,7 @@ a[low : high]
-constructs a substring or slice. The index expressions low
and
+constructs a substring or slice. The indices low
and
high
select which elements appear in the result. The result has
indices starting at 0 and length equal to
high
- low
.
@@ -2619,7 +2619,7 @@ s[2] == 4
-For convenience, any of the index expressions may be omitted. A missing low
+For convenience, any of the indices may be omitted. A missing low
index defaults to zero; a missing high
index defaults to the length of the
sliced operand:
The assignment proceeds in two phases. -First, the operands of index expressions +First, the operands of index expressions and pointer indirections (including implicit pointer indirections in selectors) on the left and the expressions on the right are all -- 2.48.1