Open mchirico opened 3 years ago
In Go, you can pass functions as parameters to other functions. Here's an example...
Video Day 2 Repil.it
package main import ( "fmt" ) type someFunction func(int) (string, error) func Thingy(s someFunction) (string, error) { return s(4) } func main() { result, err := Thingy(func(x int) (string, error) { return fmt.Sprintf("Number: %d", x), nil }) fmt.Println(result, err) }
mchirico, Thanks for opening this issue!
Functions as Parameters
In Go, you can pass functions as parameters to other functions. Here's an example...
Video Day 2 Repil.it