Example of upto that prints out a times table for 2 : upto « Statement « Ruby






Example of upto that prints out a times table for 2


1.upto(12) { |i| print "2 x " + i.to_s + " = ", i * 2, "\n"}

 








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.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 {}