Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created August 10, 2012 20:26
Show Gist options
  • Save leejarvis/3317594 to your computer and use it in GitHub Desktop.
Save leejarvis/3317594 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Array struct {
Elems []interface{}
}
func (a *Array) push(object interface{}) {
a.Elems = append(a.Elems, object)
}
func (a *Array) each(f func(interface{})) {
for _, item := range a.Elems {
f(item)
}
}
func main() {
items := new(Array)
items.push("foo")
items.each(func(item interface{}) {
fmt.Println(item)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment