Commit ada65575 authored by griesemer's avatar griesemer Committed by Robert Griesemer

spec: simplify paragraph on certain range expressions over arrays

Fixes #22258.

Change-Id: I43e68f1cf3163e1a041ebff2734ff2cb7943f695
Reviewed-on: https://go-review.googlesource.com/71431Reviewed-by: 's avatarRob Pike <r@golang.org>
Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 3813f941
......@@ -5028,12 +5028,10 @@ the range clause is equivalent to the same clause without that identifier.
</p>
<p>
The range expression is evaluated once before beginning the loop,
with one exception: if the range expression is an array or a pointer to an array
and at most one iteration variable is present, only the range expression's
length is evaluated; if that length is constant,
<a href="#Length_and_capacity">by definition</a>
the range expression itself will not be evaluated.
The range expression <code>x</code> is evaluated once before beginning the loop,
with one exception: if at most one iteration variable is present and
<code>len(x)</code> is <a href="#Length_and_capacity">constant</a>,
the range expression is not evaluated.
</p>
<p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment