Is there a quick way to get every other entry in an Array in Ruby? Either the odd or even entries values with 0 included in the odd. I'd like to be able to use it like this:
array1 += array2.odd_values
or
puts array2.odd_values.join("-")
for example
Update
This give exactly what I'm after but I'm sure there is a shorter version.
array1.each_with_index do |item,index|
if (index %2 ==0) then
array2.push(item)
end
end
0th
element in the evens.