Ruby is unique in the “more than one way to do the same thing” and while (no pun intended) for/while loops may not be as common, they were made for developers entering ruby from other languages particularly java and php (I don’t have source for this, will look it up)
I'm a Systems Reliability and DevOps engineer for Netdata Inc. When not working, I enjoy studying linguistics and history, playing video games, and cooking all kinds of international cuisine.
Ruby is not as unique in that respect as you think.
There are not one, not two, but three ways to loop over an array in JavaScript, and that's not counting special cases like map, reduce, or filter. You have classic C-style for loops, 'for...of' loops (iteration), and the callback-based .forEach() approach.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby is unique in the “more than one way to do the same thing” and while (no pun intended)
for/while
loops may not be as common, they were made for developers entering ruby from other languages particularly java and php (I don’t have source for this, will look it up)Ruby is not as unique in that respect as you think.
There are not one, not two, but three ways to loop over an array in JavaScript, and that's not counting special cases like map, reduce, or filter. You have classic C-style for loops, 'for...of' loops (iteration), and the callback-based
.forEach()
approach.