Created
February 10, 2014 06:09
-
-
Save wingyplus/8911112 to your computer and use it in GitHub Desktop.
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" | |
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