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

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

instance method Integer#%

self % other -> NumericRuby 2.4.0 から[permalink][rdoc][edit]
modulo(other) -> Numeric

算術演算子。剰余を計算します。

p 13 % 4  # =>  1
p 13 % -4 # => -3
p -13 % 4 # =>  3
p -13 % -4  # => -1
[PARAM] other:
二項演算の右側の引数(対象)
[RETURN]
計算結果