Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
Created November 9, 2010 00:46
Show Gist options
  • Save drewlesueur/668537 to your computer and use it in GitHub Desktop.
Save drewlesueur/668537 to your computer and use it in GitHub Desktop.
Example of a closure in CoffeeScript
person = () ->
name = "Fred"
ret =
getName: () ->
return name
setName: (newName) ->
name = newName
bob = person()
alert bob.getName()
bob.setName("Bob")
alert bob.getName()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment