Skip to content

Instantly share code, notes, and snippets.

@robertscherbarth
Created July 25, 2018 08:20
Show Gist options
  • Save robertscherbarth/bb0af1e4c9e112cd64f872adeb1132d3 to your computer and use it in GitHub Desktop.
Save robertscherbarth/bb0af1e4c9e112cd64f872adeb1132d3 to your computer and use it in GitHub Desktop.
Higher Order functions in golang
package main
import (
"fmt"
)
func getIncrementer() func() int {
i := -1
return func() int {
i = i + 1
return i
}
}
func main() {
increment := getIncrementer()
fmt.Println(increment())
fmt.Println(increment())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment