diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-26 11:06:17 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-26 11:06:17 +0000 |
commit | 8d446fe1eb85af0397640fff791499c2fca470e0 (patch) | |
tree | 7735a78669b7674cc97cffe62b62fe8594739e04 /array.c | |
parent | 327d58f72057395a3f3960a14117be801575ec5a (diff) |
* array.c (rb_ary_cmp): Array#<=> returns nil when comparison fails
[ruby-core:26316]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -2963,7 +2963,7 @@ recursive_cmp(VALUE ary1, VALUE ary2, int recur) /* * call-seq: - * array <=> other_array -> -1, 0, +1 + * array <=> other_array -> -1, 0, +1, nil * * Comparison---Returns an integer (-1, 0, * or +1) if this array is less than, equal to, or greater than @@ -2987,7 +2987,8 @@ rb_ary_cmp(VALUE ary1, VALUE ary2) long len; VALUE v; - ary2 = to_ary(ary2); + ary2 = rb_check_array_type(ary2); + if (NIL_P(ary2)) return Qnil; if (ary1 == ary2) return INT2FIX(0); v = rb_exec_recursive_paired(recursive_cmp, ary1, ary2, ary2); if (v != Qundef) return v; |