From: Rick DeNatale Date: 2008-01-05T02:52:37+09:00 Subject: Re: Enumerable#zip Needs Love By the way the RDOC for Enumerable#zip for 1.9 seems to need some work: k$ ri1.9 Enumerable#zip --------------------------------------------------------- Enumerable#zip enum.zip(arg, ...) => enumerator enum.zip(arg, ...) {|arr| block } => nil ------------------------------------------------------------------------ Takes one element from _enum_ and merges corresponding elements from each _args_. This generates a sequence of _n_-element arrays, where _n_ is one more that the count of arguments. The length of the sequence is truncated to the size of the shortest argument (or _enum_). 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]] Note that although the signature says that calling it without a block will return an enumerator, the examples show it returning an array. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/