在Ruby中,有没有快速获取数组中所有其他项的方法?奇数或偶数项的值中包含0.我希望能够像这样使用它:
array1 += array2.odd_values
或
puts array2.odd_values.join("-")
f或 example
更新
This give exactly what I'm after but I'm sure there is a sh或ter version.
array1.each_with_index do |item,index|
if (index %2 ==0) then
array2.push(item)
end
end