以下给出了与匿名函数相关的语法错误:
my_function = (f, x, str) ->
alert str + f(x)
my_function (x) -> 1 + x, 12, "The answer is: "
以下作品:
my_function = (f, x, str) ->
alert str + f(x)
increment = (x) -> x + 1
my_function increment, 12, "The answer is: "
答案 0 :(得分:3)
my_function ((x) -> x + 1), 12, "The answer is: "
那应该解决它。