このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 3.0 リファレンスマニュアル

instance method Integer#downto

downto(min) {|n| ... } -> self[permalink][rdoc][edit]
downto(min) -> Enumerator

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

[PARAM] min:
数値
[RETURN]
self を返します。
2.downto(-1) { |i| p i }
# => 2
#    1
#    0
#    -1

[SEE_ALSO] Integer#upto, Numeric#step, Integer#times