[DOC] Tweaks for Module#<=>

This commit is contained in:
Burdette Lamar 2025-11-28 19:27:35 -06:00 committed by GitHub
parent 688350dacc
commit 005fba0713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-11-29 01:28:03 +00:00
Merged: https://github.com/ruby/ruby/pull/15298

Merged-By: peterzhu2118 <peter@peterzhu.ca>

View File

@ -2012,14 +2012,26 @@ rb_mod_gt(VALUE mod, VALUE arg)
/*
* call-seq:
* module <=> other_module -> -1, 0, +1, or nil
* self <=> object -> -1, 0, +1, or nil
*
* Comparison---Returns -1, 0, +1 or nil depending on whether +module+
* includes +other_module+, they are the same, or if +module+ is included by
* +other_module+.
* Returns:
*
* - +-1+, if +self+ includes +object+, if or +self+ is a subclass of +object+.
* - +0+, if +self+ and +object+ are the same.
* - +1+, if +object+ includes +self+, or if +object+ is a subclass of +self+.
* - +nil+, if none of the above is true.
*
* Examples:
*
* # Class Array includes module Enumerable.
* Array <=> Enumerable # => -1
* Enumerable <=> Enumerable # => 0
* Enumerable <=> Array # => 1
* # Class File is a subclass of class IO.
* File <=> IO # => -1
* IO <=> File # => 1
* File <=> File # => 0
*
* Returns +nil+ if +module+ has no relationship with +other_module+, if
* +other_module+ is not a module, or if the two values are incomparable.
*/
static VALUE