0
下面給出相關的匿名函數語法錯誤:在CoffeeScript中,如何使用匿名函數作爲參數進行函數調用?
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: "
重複http://stackoverflow.com/questions/6463052/how-to-pass-two-anonymous-functions-as-arguments-in-coffescript。另見http://stackoverflow.com/questions/6459630/how-to-write-settimeout-with-params-by-coffeescript –