downTo

.downTo( min ) { |i| ... }

This is similar to upTo, only it works in the opposite direction. When called it will yield each value from this number, down to the min given. If min is greater then this, then no iteration is performed.

// prints each value from 20 to 11, on the console
20.downTo( 10 ) do |i|
    console( i )
end

.downTo( min, step ) { |i| ... }

This version of downTo takes a step value, which states how much to increment each time it yields.

// prints each value from 20 to 10.5,
// with increments of 0.5
20.downTo( 10, 0.5 ) do |i|
    console( i )
end

You might notice that 0.5 is a positive, even though it iterates in the negative direction. Step is automatically adjusted to be used in the correct direction, to avoid accidental infinite loops.