Skip to content

Instantly share code, notes, and snippets.

@vlasovskikh
Created July 23, 2011 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlasovskikh/1101352 to your computer and use it in GitHub Desktop.
Save vlasovskikh/1101352 to your computer and use it in GitHub Desktop.
Local vars in CoffeeScript are nonlocal sometimes
f = ->
x = 2
x = 1
> console.debug "x = #{ x }"
x = 1
> console.debug "f() = #{ f() }"
f() = 2
> console.debug "x = #{ x }"
x = 1
x = 1
f = ->
x = 2
> console.debug "x = #{ x }"
x = 1
> console.debug "f() = #{ f() }"
f() = 2
> console.debug "x = #{ x }"
x = 2
@vlasovskikh
Copy link
Author

@autotelicum Thanks for these very relevant links! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment