如果我只想要它的特定部分,我试图弄清楚是否应该避免以这种方式循环遍历数组。
the_count = [1, 2, 3, 4, 5]
fruits = ["apples", "oranges", "pears", "apricots"]
for number in the_count
puts "This is count #{number}"
end
fruits.each do |fruit|
puts "A fruit of type: #{fruit}"
end
提前致谢!