Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Module#<=

(::Module other) -> bool?
self <= other → true, false, or nil

Compares self and other with respect to ancestry and inclusion.

Returns nil if there is no such relationship between the two:

Example
Array <= Hash       # => nil

Otherwise, returns true if other is an ancestor of self, or if self includes other, or if the two are the same:

Example
File  <= IO         # => true  # IO is an ancestor of File.
Array <= Enumerable # => true  # Array includes Enumerable.
Array <= Array      # => true

Otherwise, returns false:

Example
IO         <= File  # => false
Enumerable <= Array # => false
See also #< #<=> .used_refinements #== also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0