use curly braces ({}): : upto « Statement « Ruby






use curly braces ({}):



fruits = ["peaches", "pumpkins", "apples", "oranges"]

0.upto(fruits.length - 1) { |loop_index|
  print fruits[loop_index] + " "
}

 








Related examples in the same category

1.use the upto iterator, which is what traditional for loops translate into in Ruby.
2.Use an upto Iterator to reference array element
3.uses the upto iterator to create a loop similar to a for loop from other languages
4.The upto Method and for loop
5.Example of upto that prints out a times table for 2
6.do all the times tables from 1 to 12
7.One date may upto another
8.Interpolation with upto and array
9.upto with / without {}