Created
August 5, 2014 15:25
-
-
Save chespinoza/706c8f33966dbbff54db to your computer and use it in GitHub Desktop.
Uhmm Go have first class functions
This file contains hidden or 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
// 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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking how to pass functions as parameters..