Created
November 3, 2016 01:34
-
-
Save code-shoily/97609a0fd419e8c291001e4b71631a63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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