Issue #11878 has been updated by mame (Yusuke Endoh).
Status changed from Assigned to Rejected
The current behavior is consistent. The rdoc of `Module#<` says:
```
call-seq:
mod < other -> true, false, or nil
Returns true if <i>mod</i> is a subclass of <i>other</i>.
```
Note that subclass is not directly related to the method lookup order. Consider the following example:
```
module M; end
class C; prepend M; end
C.new.is_a?(M) #=> true
```
This means `C` is a subclass of `M`. So, `C < M` should return true. Note that, in terms of method lookup, `M` has a higher priority than 'C'.
----------------------------------------
Bug #11878: Comparison of prepended modules
https://bugs.ruby-lang.org/issues/11878#change-83358
* Author: sawa (Tsuyoshi Sawada)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
* ruby -v: 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED
----------------------------------------
Including module `B` to class/module `A` gives the following results (as expected):
~~~ruby
module A; end
module B; end
A.include B
A < B # => true
B < A # => false
A <=> B # => -1
~~~
And prepending module `C` to `A` gives the following results:
~~~ruby
module C; end
A.prepend C
A < C # => true
C < A # => nil
A <=> C # => -1
~~~
It looks like including and prepending almost do not make difference with respect to module comparison, i.e., `A < B` and `A < C` are the same, and `A <=> B` and `A <=> C` are the same. However, then, the difference between `B < A` and `C < A` stands out unexplained. I suppose this is a bug. If `C < A` were to return `false`, then it would be at least consistent.
However, if that was what was intended, then at least to me, it is strange. In that case, I would like to make this a feature request. I would rather expect:
~~~ruby
A < C # => false
C < A # => true
A <=> C # => 1
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.