[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Array.collect





On Thu, Dec 6, 2018, 9:05 PM <marigoldmaripol@xxxxxxxxx wrote:
I'd like to take a large array and collect it into a smaller array,
using every fourth value. Is there a method for this?

You could do

a.select{|e,i| i.mod(4) == 0}

or

a[(0..a.size.div(4))*4]

Brian