Equivalent Ruby .times in Coffeescript

前端 未结 3 2143
[愿得一人]
[愿得一人] 2021-02-11 13:39

What is the most concise equivalent Coffeescript to the following:

# ruby    
3.times { puts \'hi\' }

?

The best I could think of is:

3条回答
  •  礼貌的吻别
    2021-02-11 14:01

    Since you're already using Underscore.js along with CoffeeScript:

    _(3).times -> console.log('hi')
    

提交回复
热议问题