Skip to content

Instantly share code, notes, and snippets.

@code-shoily
Created November 3, 2016 01:34
Show Gist options
  • Save code-shoily/97609a0fd419e8c291001e4b71631a63 to your computer and use it in GitHub Desktop.
Save code-shoily/97609a0fd419e8c291001e4b71631a63 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Func func()
func main() {
var callUs []Func
listOfNumbers := [...]int{1, 2, 3, 4, 5}
for _, v := range listOfNumbers {
callUs = append(callUs, func() { fmt.Println(v) })
}
for _, v := range callUs {
v()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment