I am using Ruby on Rails 3.0.7 and I would like to know what is a common practice\technique to iterate an array composed from a lot of data and fire an event each three iterations.
I can do something like this
# "fire_the_event" is a method
count = 0
array.each do |element|
count += 1
fire_the_event if count % 3 == 0
end
but there is a “better”\”more performant” way to fire_the_event each three times?
You can use the
each_slicemethod