How to iterate through an array in Ruby

#A. Create an array
names = %w[chris sandy josie billy suzie]

#B. Find the length of the array and iterate through it
names.length.times do |i|
puts i.to_s + " " + names[i]
end

source

Leave a Reply