Interpolation with upto and array : upto « Statement « Ruby






Interpolation with upto and array


array = ['junk', 'junk', 'junk', 'val1', 'val2']
3.upto(array.length-1) { |i| puts "Value #{array[i]}" }
# Value val1
# Value val2

 








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.use curly braces ({}):
5.The upto Method and for loop
6.Example of upto that prints out a times table for 2
7.do all the times tables from 1 to 12
8.One date may upto another
9.upto with / without {}