colors = ['red', 'green', 'blue']
colors.each_with_index do |item, index|
p "#{index}:#{item}"
end
"0:red"
"1:green"
"2:blue"
['a', 'b', 'c', 'd', 'e'].each_cons(3).to_a.each_with_index {|(previous, current, nekst), i|
puts "#{i + 1}. #{previous} - #{current} - #{nekst}"
}
#returns consective elements with their indexes
####################Another way can be this#################
['a', 'b', 'c', 'd', 'e'].each_cons(3).with_index{|array_3,index| p a; p b}