是的`do ... while`循环遗漏了CoffeeScript ...? [英] Were `do...while` loops left out of CoffeeScript...?

查看:163
本文介绍了是的`do ... while`循环遗漏了CoffeeScript ...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CoffeeScript中, while 循环标准:

  while但是,以下 1  

不工作:

  do 
y()
while x()

这只是第一个例子的糖:

  y()while x()



<

解决方案

CoffeeScript文档说:


CoffeeScript提供的唯一的低级循环是while循环。


我不知道一个内置循环执行至少一次,所以我想替代是

  loop 
y()
break if x()


In CoffeeScript, the while loop comes standard:

while x()
   y()

However, the following1 doesn't work:

do
  y()
while x()

And this is simply sugar for the first example:

y() while x()

Does CoffeeScript come with a built-in loop that executes at least once?

1As an aside, do is a keyword — it's used to call anonymous functions.

解决方案

The CoffeeScript documentation says:

The only low-level loop that CoffeeScript provides is the while loop.

I don't know of a built-in loop that executes at least once, so I guess the alternative is

loop
  y()
  break if x()

这篇关于是的`do ... while`循环遗漏了CoffeeScript ...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆