diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-19 21:47:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-19 21:47:48 +0000 |
commit | 1dd21576f2ded2acb7b49e2057df9ee064ac1fd2 (patch) | |
tree | 52b386db09c7aaa1c95a210a9411d7423f1c4170 /array.c | |
parent | 9aec42d205740247c9c04aa6956af6c556ed3439 (diff) | |
download | ruby-1dd21576f2ded2acb7b49e2057df9ee064ac1fd2.tar.gz ruby-1dd21576f2ded2acb7b49e2057df9ee064ac1fd2.tar.xz ruby-1dd21576f2ded2acb7b49e2057df9ee064ac1fd2.zip |
* array.c (take_items), enum.c (enum_zip): tries to convert to
array first. [ruby-core:21442]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -2209,9 +2209,11 @@ take_i(VALUE val, VALUE *args, int argc, VALUE *argv) static VALUE take_items(VALUE obj, long n) { - VALUE result = rb_ary_new2(n); + VALUE result = to_ary(obj); VALUE args[2]; + if (!NIL_P(result)) return rb_ary_subseq(result, 0, n); + result = rb_ary_new2(n); args[0] = result; args[1] = (VALUE)n; rb_block_call(obj, rb_intern("each"), 0, 0, take_i, (VALUE)args); return result; |