0
我刚刚开始使用Coffeescript并运行“Programming in CoffeeScript book”中介绍的示例。在While循环语法中传递匿名变量
在while循环部分,我很感兴趣为什么要调用times函数必须声明如下。
times = (number_of_times, callback) ->
index = 0
while index++ < number_of_times
callback(index)
return null
times 5, (index) ->
console.log index
我挣扎了一下,阅读代码,当我已经试过:
times (5, (index)) ->
console.log index
它返回一个错误。 请你帮忙理解这段代码吗?
请附上您在文章中提到的错误消息。 – 2013-03-17 16:52:53
我不明白这个问题。请修正缩进 – Ven 2013-03-17 17:16:00