ruby iterate over array
# For Ruby arr = ['a', 'b', 'c'] arr.each do |item| puts item end
ruby how to loop through an array
array = [1, 2, 3, 4, 5, 6] array.each { |x| puts x }
Source: stackoverflow.com
ruby loop through array
numbers = [0, 1, 2, 3] for element in numbers do puts element end
ruby array loop
array = ["A", "B", "C"] array.each_with_index {|val, index| puts "#{val} => #{index}" } # Output: A => 0 B => 1 C => 2
Source: stackoverflow.com