Skip to content

Commit db5f2b4

Browse files
griesemergopherbot
authored andcommitted
spec: clarify when a range expression is evaluated
If the range expression is a numeric constant, the range expression is also not evaluated. Change-Id: I97201e5c136d3d1a87ed1500b19b7199b30bc9ff Reviewed-on: https://go-review.googlesource.com/c/go/+/581298 Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Bypass: Robert Griesemer <[email protected]> Auto-Submit: Robert Griesemer <[email protected]>
1 parent 4351af6 commit db5f2b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doc/go_spec.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--{
22
"Title": "The Go Programming Language Specification",
3-
"Subtitle": "Language version go1.22 (Feb 6, 2024)",
3+
"Subtitle": "Language version go1.22 (April 24, 2024)",
44
"Path": "/ref/spec"
55
}-->
66

@@ -6644,8 +6644,8 @@ <h4 id="For_range">For statements with <code>range</code> clause</h4>
66446644

66456645
<p>
66466646
The range expression <code>x</code> is evaluated once before beginning the loop,
6647-
with one exception: if at most one iteration variable is present and
6648-
<code>len(x)</code> is <a href="#Length_and_capacity">constant</a>,
6647+
with one exception: if at most one iteration variable is present and <code>x</code> or
6648+
<a href="#Length_and_capacity"><code>len(x)</code></a> is <a href="#Constants">constant</a>,
66496649
the range expression is not evaluated.
66506650
</p>
66516651

0 commit comments

Comments
 (0)