2014-05-24 40 views

回答

1

我已经简化你的代码这一点(因为它是什么滋生的错误)

do (unique = (-> ->), x = unique()) -> 
    console.log "x is y:", x is y 

编译的版本是:

(function(unique, x) { 
    return console.log("x is y:", x === y); 
})((function() { 
    return function() {}; 
}), unique()); 

也可以这样写:

a=function(unique,x) { 
     return console.log("x is y:", x === y); 
    } 
b=(function() { 
     return function() {}; 
    }) 
a(b,unique) 

正如你所看到的,最后一个唯一值没有在范围的任何地方定义。

这就是为什么你会得到这个错误。

我建议你提取unique

unique = (-> ->) 
do (unique, x = unique()) -> 
    do (y = x) -> 
    console.log "x is y:", x is y