0

The following gives a syntax error related to the anonymous function:

my_function = (f, x, str) ->
  alert str + f(x)

my_function (x) -> 1 + x, 12, "The answer is: "

The following works:

my_function = (f, x, str) ->
  alert str + f(x)

increment = (x) -> x + 1

my_function increment, 12, "The answer is: "
Geoff
  • 9,470
  • 13
  • 52
  • 67
  • 1
    Duplicate of http://stackoverflow.com/questions/6463052/how-to-pass-two-anonymous-functions-as-arguments-in-coffescript. See also http://stackoverflow.com/questions/6459630/how-to-write-settimeout-with-params-by-coffeescript – Trevor Burnham Jul 17 '11 at 03:03

1 Answers1

3
my_function ((x) -> x + 1), 12, "The answer is: "

That should fix it.

Florian Mayer
  • 3,041
  • 24
  • 17