Created
November 23, 2016 21:07
-
-
Save adamryman/cbaf60e2a5932c291d1eb90ad07c8698 to your computer and use it in GitHub Desktop.
this is how we closure
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 | |
func main() { | |
var test closure | |
test = foo | |
for { | |
test = test() | |
} | |
} | |
type closure func() closure | |
func foo() closure { | |
i := 0 | |
var bar closure | |
bar = func() closure { | |
print(i) | |
i = i + 1 | |
if i > 3000 { | |
return foo | |
} | |
return bar | |
} | |
return bar | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment