Skip to content

Instantly share code, notes, and snippets.

@gzmask
Forked from divoxx/gist:315024
Created February 25, 2010 20:59
Show Gist options
  • Save gzmask/315028 to your computer and use it in GitHub Desktop.
Save gzmask/315028 to your computer and use it in GitHub Desktop.
each function
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