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

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

instance method Module#>

self > other -> bool | nil[permalink][rdoc][edit]

比較演算子。 self が other の先祖である場合、true を返します。 self が other の子孫か同一クラスである場合、false を返します。

継承関係にないクラス同士の比較では nil を返します。

[PARAM] other:
比較対象のモジュールやクラス
[EXCEPTION] TypeError:
other がクラスやモジュールではない場合に発生します。

[SEE_ALSO] Module#<

module Awesome; end
module Included
  include Awesome
end
module Prepended
  prepend Awesome
end

p Included.ancestors # => [Included, Awesome]
p Awesome > Included # => true
p Included > Awesome # => false

p Prepended.ancestors # => [Awesome, Prepended]
p Awesome > Prepended # => true
p Prepended > Awesome # => false

p Awesome > Awesome # => false
p Awesome > Object # => nil