Skip to content

Instantly share code, notes, and snippets.

@gregworley
Created September 22, 2010 15:30
Show Gist options
  • Save gregworley/591894 to your computer and use it in GitHub Desktop.
Save gregworley/591894 to your computer and use it in GitHub Desktop.
Golang GoCourseDay1.pdf slide 53
package main
import "fmt"
func adder() (func(int) int) { //declare function adder() with the function literal func(int) as a parameter of type int
var x int
return func(delta int) int {
x += delta
return x
}
}
func main() {
var f = adder()
fmt.Print(f(1))
fmt.Print(f(1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment