Saturday, January 11, 2014

[Rails] Re: each.with_index


As Dave answered, modulus is your answer -

a.each_with_index do |obj, idx|
   if (idx % 5 == 0)
      # this is your starting point for each group of 5

   end

   # do other stuff here...

end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6126a020-16d9-45a9-9906-a24aaa899f41%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate