Last active
January 29, 2018 03:33
-
-
Save dt665m/34bfff900d9b92c0660c122fe20052a9 to your computer and use it in GitHub Desktop.
Golang Lambdas and Thunks
This file contains 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 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