coffeescript 新手,请多多指教。
coffee上的代码是:
refine = (wheat,chaff...) ->
console.log "The best: #{wheat}"
console.log "The rest: #{chaff.join(',')}"
refine 'one','two','three','four'
编译出来后:
(function() {
var refine,
__slice = [].slice;
refine = function() {
var chaff, wheat;
wheat = arguments[0], chaff = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
console.log("The best: " + wheat);
return console.log("The rest: " + (chaff.join(',')));
};
refine('one', 'two', 'three', 'four');
}).call(this);
refine函数里面最后一行,多了return,实际中应该不需要这个return的,为什么会被这样编译出来呢?
需要去掉吗?怎么去掉?
不需要去掉吗?为什么?
最后一行写一个return或者undefined
refine = (wheat,chaff...) ->
console.log "The best: #{wheat}"
console.log "The rest: #{chaff.join(',')}"
return
refine 'one','two','three','four'
or
refine = (wheat,chaff...) ->
console.log "The best: #{wheat}"
console.log "The rest: #{chaff.join(',')}"
undefined
refine 'one','two','three','four'
http://stackoverflow.com/questions/7391493/is-there-any-way-to-not-ret...
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。