Skip to content

Instantly share code, notes, and snippets.

@titanjer
Created January 28, 2013 06:41
Show Gist options
  • Save titanjer/4653505 to your computer and use it in GitHub Desktop.
Save titanjer/4653505 to your computer and use it in GitHub Desktop.
# ref: http://blog.eddie.com.tw/2011/11/18/dash-rocket-vs-fat-arrow-in-coffeescript/
class A
constructor: (@msg) ->
thin: -> console.log @msg
fat: => console.log @msg
x = new A("yo")
x.thin() # alerts "yo"
x.fat() # alerts "yo"
global.msg = "kerker"
fn = (callback) ->
callback()
fn(x.thin) # alerts "kerker"
fn(x.fat) # alerts "yo"
fn(-> x.thin()) # alerts "yo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment