DEV Community

Discussion on: Why avoid Ruby's for .. in?

Collapse
 
ben profile image
Ben Halpern

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. πŸ˜„

Collapse
 
phallstrom profile image
Philip Hallstrom

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 can each that I'm aware of. Which is a huge part of Ruby's Enumerable ecosystem.