Skip to content

Instantly share code, notes, and snippets.

@chespinoza
Created August 5, 2014 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chespinoza/706c8f33966dbbff54db to your computer and use it in GitHub Desktop.
Save chespinoza/706c8f33966dbbff54db to your computer and use it in GitHub Desktop.
Uhmm Go have first class functions
// Playing with functions
// This is really useful
package main
import "fmt"
func greet() {
fmt.Println("Hello!")
}
func farewell() {
fmt.Println("GoodBye!")
}
type fn func()
func machine(f fn) {
f()
}
func main() {
machine(greet)
machine(farewell)
}
@chespinoza
Copy link
Author

Looking how to pass functions as parameters..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment