Skip to content

Instantly share code, notes, and snippets.

@tomfaulhaber
Created May 4, 2011 17:29
Show Gist options
  • Save tomfaulhaber/955623 to your computer and use it in GitHub Desktop.
Save tomfaulhaber/955623 to your computer and use it in GitHub Desktop.
Multi-line, multi-lambdas in coffeescript?
# I want to be able to spread multiple lambda args across multiple lines, but
# I'm unclear on the syntax
# The following gives me
# "Error: In XXX/dashboard.coffee, Parse error on line 125: Unexpected ','"
# whether I put it on one line or multiple lines.
$("ul.topnav > li").hover(
( -> $(this).find("span").addClass "subhover"),
( -> $(this).find("span").removeClass "subhover"))
@tomfaulhaber
Copy link
Author

It seems like the above syntax works, but things fail when the lambdas are themselves split. To get it to be reliable, I needed to put the closing paren for the hover call on its own line.

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