Skip to content

Instantly share code, notes, and snippets.

@metasansana
Created September 1, 2013 14:58
Show Gist options
  • Save metasansana/6404950 to your computer and use it in GitHub Desktop.
Save metasansana/6404950 to your computer and use it in GitHub Desktop.
Go language closure.
func outer (outerArg int) func(int) { //this could also be a custom type
return func (innerArg int) int { // closure func
return outerArg+innerArg;
}
}
//Usage
var result = outer(1)(2); // result will be equal to 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment