CoffeeScript 1.9.0 发布了 带来了ES6 generator functions
发布于 11 年前 作者 gloomyzerg 6593 次预览 最后一次回复是 11 年前 来自 分享
coffee :
perfectSquares = ->
num = 0
loop
num += 1
yield num * num
return
window.ps or= perfectSquares()
javascript :
var perfectSquares;
perfectSquares = function*() {
var num;
num = 0;
while (true) {
num += 1;
(yield num * num);
}
};
window.ps || (window.ps = perfectSquares());
详情见 http://coffeescript.org/#fat-arrow
我的koa啊 …
6 回复
兴奋一下吧
太赞了,一个yield解决问题
搜了搜,还没加入
yield *es6 之后 要Coffee Script意义不大了~感觉
@freew01f 同感
@freew01f 其实coffee这东西 没啥意义不意义的 我以前从来都不用这种语法糖 但是用的人多了 为了和别人交流 只能也用了
反正这东西的学习成本也就几分钟的事