Created
February 19, 2017 13:59
-
-
Save maniankara/21cebdc3ef2001e0892ce62c4943615c to your computer and use it in GitHub Desktop.
simple firstclass function: assigning function to variable
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
package fragments | |
import "os" | |
func dummy() { | |
// define | |
createFile := func (path string) *os.File { | |
tmpfn, err := os.Create(path) | |
if err != nil { | |
"Error while creating file: ", path | |
} | |
return tmpfn | |
} | |
// invoke file creation | |
createFile() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment