array = ["A", "B", "C"] array.each_with_index {|val, index| puts "#{val} => #{index}" } # Output: A => 0 B => 1 C => 2