Skip to content

Instantly share code, notes, and snippets.

@wingyplus
Created February 10, 2014 06:09
Show Gist options
  • Save wingyplus/8911112 to your computer and use it in GitHub Desktop.
Save wingyplus/8911112 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type List interface {
ForEach(f func(v int))
}
type IntList []int
func (iL IntList) ForEach(f func(v int)) {
for _, v := range []int(iL) {
f(v)
}
}
func main() {
var iL List = IntList{1, 2, 3, 4}
iL.ForEach(func (v int) {
fmt.Println(v)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment