What is the most concise equivalent Coffeescript to the following:
# ruby
3.times { puts 'hi' }
?
The best I could think of is:
# coffeescript
for n in [1..3]
console.log 'hi'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To also handle
0correctly:Or with prototype magic:
Note that the second method isn’t recommended because changing the
Numberprototype has global effects.Edit: Changed according to @BrianGenisio’s comment (
.prototype.->::)Edit 2: fixed handling of 0, thanks @Brandon