github.com/traefik/yaegi@v0.15.1/_test/closure10.go (about) 1 package main 2 3 func main() { 4 foos := []func(){} 5 6 for i := 0; i < 3; i++ { 7 a, b := i, i 8 foos = append(foos, func() { println(i, a, b) }) 9 } 10 foos[0]() 11 foos[1]() 12 foos[2]() 13 } 14 15 // Output: 16 // 3 0 0 17 // 3 1 1 18 // 3 2 2