Were `do…while` loops left out of CoffeeScript…?

前端 未结 5 508
栀梦
栀梦 2021-02-03 17:13

In CoffeeScript, the while loop comes standard:

while x()
   y()

However, the following1 doesn\'t work:



        
5条回答
  •  别那么骄傲
    2021-02-03 18:01

    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()
    

提交回复
热议问题