times

.times() { |i| ... }

Runs a loop the given number of times from 0 to this value. So if this number is 10, then it runs 10 times. On each iteration a whole number is passed into the associated do block.

// prints out the numbers from 0 to 19, on the console
20.times() do |i|
    console( i )
end

.times( step ) { |i| ... }

The step version of times allows you to state how much to increment on each iteration. This can be a decimal number.

// prints out 40 numbers from 0 to 19.5,
// i.e. 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, etc
20.times( 0.5 ) do |i|
    console( i )
end