Skip to content

Instantly share code, notes, and snippets.

@shivamMg
Created June 28, 2017 06:08
Show Gist options
  • Select an option

  • Save shivamMg/1b4b17b28a794582948c9b6908991d0b to your computer and use it in GitHub Desktop.

Select an option

Save shivamMg/1b4b17b28a794582948c9b6908991d0b to your computer and use it in GitHub Desktop.
# Python
def counter(x):
def f():
nonlocal x
x += 1
return x
return f
// Golang
func counter(x int) func() int {
return func() int {
x += 1
return x
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment