Skip to content

Instantly share code, notes, and snippets.

@dlbas
Last active February 27, 2021 05:37
Show Gist options
  • Save dlbas/b0d8c8fd981e1454cec9ed5865ca714c to your computer and use it in GitHub Desktop.
Save dlbas/b0d8c8fd981e1454cec9ed5865ca714c to your computer and use it in GitHub Desktop.
package main
import "fmt"
func foo(n int) (f1 func(int) int, f2 func(int) int) {
f1 = func(i int) int {
n += i
return n
}
f2 = func(i int) int {
n -= i
return n
}
return
}
func main() {
f, g := foo(5)
fmt.Println(f(1))
fmt.Println(f(1))
fmt.Println(f(1))
fmt.Println(f(1))
fmt.Println(g(1))
fmt.Println(g(1))
fmt.Println(g(1))
fmt.Println(g(1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment