func fib() func() int {
a, b := 0, 1
return func() int {
a, b = b, a+b
return b
}
}
func main() {
f := fib()
for x := f(); x < 100; x = f() {
fmt.Println(x) // Prints fibonacci numbers less than 100
}
}
thing() above - it is a function that returns an int alongside the environment containing references to the values a and b