Skip to content

Instantly share code, notes, and snippets.

@adamryman
Created November 23, 2016 21:07
Show Gist options
  • Save adamryman/cbaf60e2a5932c291d1eb90ad07c8698 to your computer and use it in GitHub Desktop.
Save adamryman/cbaf60e2a5932c291d1eb90ad07c8698 to your computer and use it in GitHub Desktop.
this is how we closure
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