Use an upto Iterator to reference array element : upto « Statement « Ruby
- Ruby
- Statement
- upto
Use an upto Iterator to reference array element
fruits = ["peaches", "pumpkins", "apples", "oranges"]
print "We offer "
0.upto(fruits.length - 1) do |loop_index|
print fruits[loop_index] + " "
end
Related examples in the same category