From 61e02ee901e361586291087a986680ee98da6da0 Mon Sep 17 00:00:00 2001
From: Russ Cox
-The range expression is evaluated once before beginning the loop -except if the expression is an array, in which case, depending on -the expression, it might not be evaluated (see below). +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 only the first iteration value is present, only the range expression's +length is evaluated; if that length is constant by definition +(see §Length and capacity), +the range expression itself will not be evaluated. +
+ +Function calls on the left are evaluated once per iteration. For each iteration, iteration values are produced as follows:
@@ -4396,8 +4402,8 @@ channel c chan E, <-chan E element e Ea
, the index iteration
-values are produced in increasing order, starting at element index 0. As a special
-case, if only the first iteration variable is present, the range loop produces
+values are produced in increasing order, starting at element index 0.
+If only the first iteration variable is present, the range loop produces
iteration values from 0 up to len(a)
and does not index into the array
or slice itself. For a nil
slice, the number of iterations is 0.