From: "ujihisa ." Date: 2009-12-24T07:15:13+09:00 Subject: [ruby-core:27300] [Feature #1697](Assigned) Object#<=> Issue #1697 has been updated by ujihisa .. Status changed from Open to Assigned As Marc-Andre says, the current following code is redundant. static VALUE rb_obj_cmp(VALUE obj1, VALUE obj2) { if (obj1 == obj2 || rb_obj_equal(obj1, obj2)) return INT2FIX(0); return Qnil; } where VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { if (obj1 == obj2) return Qtrue; return Qfalse; } in short, the original code means static VALUE rb_obj_cmp(VALUE obj1, VALUE obj2) { if (obj1 == obj2 || ((obj1 == obj2) ? Qtrue : Qfalse)) return INT2FIX(0); return Qnil; } As Marc-Andre says, there are two alternatives which are better than current code. If you prefer to allow Ruby to change the behavior of `Object#<=>` by overwriting `Object#==`, apply the patch he showed. (Current RubySpec is based on it) Otherwise, how about applying this patch: diff --git a/object.c b/object.c index 503a7c5..3dd3290 100644 --- a/object.c +++ b/object.c @@ -1131,7 +1131,7 @@ rb_obj_not_match(VALUE obj1, VALUE obj2) static VALUE rb_obj_cmp(VALUE obj1, VALUE obj2) { - if (obj1 == obj2 || rb_obj_equal(obj1, obj2)) + if (obj1 == obj2) return INT2FIX(0); return Qnil; } I'll fix the corresponding RubySpec after you decided which behavior is preferable. ---------------------------------------- http://redmine.ruby-lang.org/issues/show/1697 ---------------------------------------- http://redmine.ruby-lang.org