in the lang spec <https://go.dev/ref/spec#For_statements>, it says:
*The range expression x is evaluated once before beginning the loop, with 
one exception: if at most one iteration variable is present and len(x) is 
constant, the range expression is not evaluated.*

https://go.dev/play/p/frLAvStOrDu

first range expr will be evaluated.

second range expr will not be evaluated.

third range expr will be evaluated.

is this correct?

and 

does the range expr will be evaluated means when range expr is slice, the 
slice header will be copy, and when range expr is array, array will be coy?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/21761606-5f09-4ae6-802e-a79636b9e957n%40googlegroups.com.

Reply via email to