Created
September 13, 2016 00:04
-
-
Save JeffreyBPetersen/465c144548ff280582310059499ad235 to your computer and use it in GitHub Desktop.
Pick a single value out of a multiple return in golang.
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" | |
"io/ioutil" | |
) | |
func door(number int) func(...interface{}) interface{} { | |
return func(doors ...interface{}) interface{} { | |
return doors[number] | |
} | |
} | |
func main() { | |
fmt.Printf("%s", door(0)(ioutil.ReadFile("test.txt"))) | |
} |
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
It's a new car! | |
With inspiration from "http://blog.vladimirvivien.com/2014/03/hacking-go-filter-values-from-multi.html". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment