user60382
0
Q:

ruby loop each with index

colors = ['red', 'green', 'blue']
colors.each_with_index do |item, index|
	p "#{index}:#{item}" 
end

"0:red"
"1:green"
"2:blue"
4
X.each_with_index do |item, index|
  puts "current_index: #{index}"
end
0

New to Communities?

Join the community