Mark McGranaghan e83deb7519 note
2012-09-23 16:15:55 -07:00

23 lines
351 B
Go

// ## Closures
package main
import "fmt"
func makeEvenGenerator() func() uint {
i := uint(0)
return func() uint {
i += 2
return i
}
}
func main() {
nextEven := makeEvenGenerator()
fmt.Println(nextEven())
fmt.Println(nextEven())
fmt.Println(nextEven())
}
// todo: note example of first-class functions.