Equivalent Ruby .times in Coffeescript

前端 未结 5 2016
滥情空心
滥情空心 2021-02-11 13:25

What is the most concise equivalent Coffeescript to the following:

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

?

The best I could think of is:

5条回答
  •  故里飘歌
    2021-02-11 14:13

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

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

提交回复
热议问题