x = [ 'apple', 'banana', 'orange' ] x.each_with_index { |val, i| print "#{i} #{val}\n" }