Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I understand. If you don't have parens on method calls, how could you use an anonymous function that is not the last parameter? For example:

  doSomething(->
    # stuff happens
  ), onerror


First, your code snippet is wrong: you need a space before your first paren.

In coffeescript you can do any of the following, or a few other variants:

  doSomething ->
      stuff
    , onerror

  doSomething(->
      stuff
    , onerror
  )

  doSomething (->
      stuff
    ), onerror

  doSomething(
    ->
      stuff
    onerror
  )

  doSomething (-> stuff), onerror


I had this question a while back as well. Take a look at the discussion here, including Jeremy's thoughts: https://gist.github.com/1215863


I totally agree with you.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: