Today I Learned

A Hashrocket project

reducing with an index in ruby

arr = [1,2,3,4,5]
arr.each_with_index.reduce([]) do |memo, (element, index)|
  # do cool code here
end

Additional bonus of the argument unpacking syntax I didn’t know about.

Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. Contact us and find out how we can help you.