diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-01 14:46:07 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-01 14:46:07 +0000 |
commit | 25ff7ef4c68ef7b6f53a8eb61ef4ec57142852b9 (patch) | |
tree | 26c2ecff4ed2b78fd5a63eac3ecc1d9a5a82c59b /array.c | |
parent | 5838fff3341e6b4ebca956a6a96659eb5afb9859 (diff) | |
download | ruby-25ff7ef4c68ef7b6f53a8eb61ef4ec57142852b9.tar.gz |
* array.c (rb_ary_combination): revisit #combination behavior.
suggested by David Flanagan.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -3028,13 +3028,11 @@ rb_ary_combination(VALUE ary, VALUE num) RETURN_ENUMERATOR(ary, 1, &num); n = NUM2LONG(num); len = RARRAY_LEN(ary); - if (n < 1 || len < n) { + if (len < n) { /* yield nothing */ } - else if (n == 0) { - for (i = 0; i < len; i++) { - rb_yield(rb_ary_new2(0)); - } + else if (n <= 0) { + rb_yield(rb_ary_new2(0)); } else if (n == 1) { for (i = 0; i < len; i++) { |