Mega Code Archive

 
Categories / Ruby / Statement
 

Uses the upto iterator to create a loop similar to a for loop from other languages

fruits = ["peaches", "pumpkins", "apples", "oranges"] 0.upto(fruits.length - 1) do |loop_index|   print fruits[loop_index] + " " end