-
-
Save gzmask/315028 to your computer and use it in GitHub Desktop.
each function
This file contains 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" | |
func Each(arr []int, iterator func(int)) { | |
for i := range arr { | |
iterator(i) | |
} | |
} | |
func main() { | |
var arr []int = make([]int, 10) | |
for i := 0; i < len(arr); i++ { arr[i] = i } | |
Each(arr, func(i int) { | |
fmt.Println(i) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment