From c3df0c8cf837c04c4a1800eaf6fd81d320b9ddb4 Mon Sep 17 00:00:00 2001 From: matz Date: Sun, 13 May 2007 17:15:25 +0000 Subject: * array.c (rb_ary_zip): a.zip(b,c) should return an array, not enumerator. * array.c (rb_ary_zip): a.zip(b,c) should return array with size truncated to the size of its shortest argument array. [incompatible] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index 42bda2f44..dc52e8f84 100644 --- a/array.c +++ b/array.c @@ -1974,18 +1974,17 @@ rb_ary_delete_if(VALUE ary) * Converts any arguments to arrays, then merges elements of * self with corresponding elements from each argument. This * generates a sequence of self.size n-element - * arrays, where n is one more that the count of arguments. If - * the size of any argument is less than enumObj.size, - * nil values are supplied. If a block given, it is - * invoked for each output array, otherwise an array of arrays is - * returned. + * arrays, where n is one more that the count of arguments. + * The size of returned array is truncated to the size of the + * shortest argument enumerable. If a block given, it is invoked + * for each output array, otherwise an array of arrays is returned. * * a = [ 4, 5, 6 ] * b = [ 7, 8, 9 ] * * [1,2,3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] * [1,2].zip(a,b) #=> [[1, 4, 7], [2, 5, 8]] - * a.zip([1,2],[8]) #=> [[4,1,8], [5,2,nil], [6,nil,nil]] + * a.zip([1,2],[8]) #=> [[4,1,8]] */ static VALUE @@ -1995,12 +1994,14 @@ rb_ary_zip(int argc, VALUE *argv, VALUE ary) long len; VALUE result; - RETURN_ENUMERATOR(ary, argc, argv); + len = RARRAY_LEN(ary); for (i=0; i RARRAY_LEN(argv[i])) + len = RARRAY_LEN(argv[i]); } if (rb_block_given_p()) { - for (i=0; i