Last active
February 27, 2021 05:37
-
-
Save dlbas/b0d8c8fd981e1454cec9ed5865ca714c to your computer and use it in GitHub Desktop.
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 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