Project

General

Profile

Actions

Bug #11878

closed

Comparison of prepended modules

Added by sawa (Tsuyoshi Sawada) over 8 years ago. Updated about 4 years ago.

Status:
Rejected
Target version:
-
ruby -v:
2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
[ruby-core:72493]

Description

Including module B to class/module A gives the following results (as expected):

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:

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:

A < C # => false
C < A # => true
A <=> C # => 1
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0