Created
September 22, 2010 15:22
-
-
Save gregworley/591869 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
func adder() (func(int) 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