Skip to content

Instantly share code, notes, and snippets.

@divoxx
Created February 25, 2010 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save divoxx/315024 to your computer and use it in GitHub Desktop.
Save divoxx/315024 to your computer and use it in GitHub Desktop.
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