DEV Community

Discussion on: Which types of loops are most popular in the programming languages you use?

Collapse
 
shushugah profile image
shushugah • Edited

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)

Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn

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.