【问题标题】:In CoffeeScript, how can you make a function call with anonymous functions as parameters?在 CoffeeScript 中,如何使用匿名函数作为参数进行函数调用?
【发布时间】:2011-10-06 22:00:58
【问题描述】:

下面给出了与匿名函数相关的语法错误:

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: "

【问题讨论】:

标签: coffeescript


【解决方案1】:
my_function ((x) -> x + 1), 12, "The answer is: "

这应该可以解决问题。

【讨论】:

    猜你喜欢
    • 2012-04-18
    • 2011-09-21
    • 1970-01-01
    • 2012-05-06
    • 2018-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多