Bug #2276

Array#<=> should not raise when comparison fails

Added by marcandre (Marc-Andre Lafortune) over 2 years ago. Updated about 1 year ago.

[ruby-core:26316]
Status:Closed Start date:10/26/2009
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:core
Target version:1.9.2
ruby -v:ruby 1.9.2dev (2009-10-25 trunk 25457) [x86_64-darwin10.0.0]

Description

Since the addition of Object#<=>, the only comparison that raised an error was Array#<=>(not_an_array).

Array#<=>(obj) now returns nil if obj is not array-like.

Maybe this should also be applied in the 1.8 line?

Note: neither test-all nor rubyspec were testing for this.

Related issues

related to ruby-trunk - Feature #1697: Object#<=> Closed 06/28/2009

Associated revisions

Revision 25491
Added by marcandre (Marc-Andre Lafortune) over 2 years ago

* array.c (rb_ary_cmp): Array#<=> returns nil when comparison fails [ruby-core:26316]

Also available in: Atom PDF