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

前端 未结 5 526
栀梦
栀梦 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 17:59

    I know that this answer is very old, but since I entered here via Google, I thought someone else might as well.

    To construct a do...while loop equivalent in CoffeeScript I think that this syntax emulates it the best and easiest and is very readable:

    while true
       # actions here
       break unless # conditions here
    

提交回复
热议问题