Thank you for adding Ruby syntax. This post was written a few year ago when I found myself always scrambling to write loop when working with different programming languages. Nowadays, a functional programming approach is preferable. I love Python and Ruby for their clean syntax.
Love the apples-to-apples comparison.
Here's Ruby:
But in practice, nobody uses for loops.
Here's a while:
But nobody uses those either.
People are way more likely to do
Or using a collection of objects, like an array or an ActiveRecord collection.
Thank you for adding Ruby syntax. This post was written a few year ago when I found myself always scrambling to write loop when working with different programming languages. Nowadays, a functional programming approach is preferable. I love Python and Ruby for their clean syntax.
Do you mind if I include your Ruby code into the post? I will put credit where it belongs.
Go for it. And no need to credit if it effects the reading in any way. π