Skip to content

Instantly share code, notes, and snippets.

@h4ck4life
Forked from cespare/gist:2402610
Created August 28, 2014 04:15
Show Gist options
  • Save h4ck4life/6f769426ee29dcfae672 to your computer and use it in GitHub Desktop.
Save h4ck4life/6f769426ee29dcfae672 to your computer and use it in GitHub Desktop.
foo = (f1, f2) ->
f1()
f2()
# Doesn't work -- syntax error
# foo(-> console.log("hi from f1"), -> console.log("hi from f2"))
# Simplest way I've found to do it -- newlines added for clarity
foo(
(-> console.log("hi from f1")),
(-> console.log("hi from f2"))
)
# Most concise way -- you can leave off the parens around the last function (thanks bkad)
foo (-> console.log("hi from f1")), -> console.log("hi from f2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment