Dear all, The spec at https://go.dev/ref/spec#For_range 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." What does the second half of this sentence mean? My guess was that this says that in "for i := range [3]int{1, 2, f()} ..." the function f is not called, but I quick experiment shows that this guess is wrong, see https://go.dev/play/p/MXqH_C7mllx . All the best, Jochen -- 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/db6d865e-233e-4120-8ce5-5feb832732b6n%40googlegroups.com.