+1 for each (second). To me, the for reminds me of other languages where you
have to tell it what type of item the collection you are iterating contains
(I am thinking of C#), but in Ruby is not really an issue. I would be
interested in other opinions but to me not using 'for' just seems 'right'
and an easier read, maybe b/c this is what I seem to see most often.

On Wed, Aug 4, 2010 at 9:26 AM, Pale Horse <li...@ruby-forum.com> wrote:

> When looping through arrays. What'd you argue to be good (or best)
> practice?
>
> <% for something in @lots_of_things %>
>  <%= something.name %>
> <% end %>
>
> <% @lots_of_things.each do |something| %>
>  <%= something.name %>
> <% end %>
>
> I've read mixed opinions on this small topic. Some say that FOR loops
> are easier, though I cannot see how. Others say that EACH is a more
> 'railsy' method...
>
> Personally, I tend to use EACH as I was taught this to be correct and
> follow this rule to retain consistency in MY code. What is your opinion
> on this?
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to