instance method Module#<

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

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

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

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


module Foo
end
class Bar
  include Foo
end
class Baz < Bar
end
class Qux
end
p Bar < Foo     # => true
p Baz < Bar     # => true
p Baz < Foo     # => true
p Baz < Qux     # => nil
p Baz > Qux     # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeError)