Skip to content

Instantly share code, notes, and snippets.

@dt665m
Last active January 29, 2018 03:33
Show Gist options
  • Save dt665m/34bfff900d9b92c0660c122fe20052a9 to your computer and use it in GitHub Desktop.
Save dt665m/34bfff900d9b92c0660c122fe20052a9 to your computer and use it in GitHub Desktop.
Golang Lambdas and Thunks
package main
import (
"fmt"
)
func main() {
var MainInt int = 500
mainFunc := func(x int) bool {
MainInt += x
return MainInt > 1000
}
fmt.Println(one(mainFunc))
fmt.Println(close(500)(100))
closefunc := close(500)
closefunc(100)
}
func one(testFunc func(x int) bool) bool {
return testFunc(100)
}
func close(x int) func(int) bool {
return func(innerX int) bool {
return (x + innerX) > 1000
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment