Performance differences seem negligible gist.github.com/jodosha/229951
As for better/cleaner, Rubyists definitely love .each, and for practical purposes, it's probably worth just drinking the kook-aid rather than stirring things up with Ruby dogma.
.each
But I'm happy to hear the bikeshedding on this. π
I've been writing Ruby for 12-13 years and have never once used or even come across for in real life. Definitely bikeshedding :)
for
More seriously though, you can't pass a lambda to a for loop like you can each that I'm aware of. Which is a huge part of Ruby's Enumerable ecosystem.
each
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
Performance differences seem negligible gist.github.com/jodosha/229951
As for better/cleaner, Rubyists definitely love
.each
, and for practical purposes, it's probably worth just drinking the kook-aid rather than stirring things up with Ruby dogma.But I'm happy to hear the bikeshedding on this. π
I've been writing Ruby for 12-13 years and have never once used or even come across
for
in real life. Definitely bikeshedding :)More seriously though, you can't pass a lambda to a
for
loop like you caneach
that I'm aware of. Which is a huge part of Ruby's Enumerable ecosystem.