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

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

In CoffeeScript, the while loop comes standard:

while x()
   y()

However, the following1 doesn\'t work:



        
5条回答
  •  Happy的楠姐
    2021-02-03 17:54

    I found this could be accomplished through a short circuit conditional:

    flag = y() while not flag? or x()
    

提交回复
热议问题