D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerable
/
Filename :
zip-i.ri
back
Copy
U:RDoc::AnyMethod[iI"zip:ETI"Enumerable#zip;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"LWith no block given, returns a new array +new_array+ of size self.size ;TI" whose elements are arrays. ;TI"-Each nested array <tt>new_array[n]</tt> ;TI":is of size <tt>other_enums.size+1</tt>, and contains:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I" The +n+-th element of self.;To;;0; [o; ; [I"5The +n+-th element of each of the +other_enums+.;T@o; ; [I"6If all +other_enums+ and self are the same size, ;TI"Lall elements are included in the result, and there is no +nil+-filling:;T@o:RDoc::Markup::Verbatim; [I"a = [:a0, :a1, :a2, :a3] ;TI"b = [:b0, :b1, :b2, :b3] ;TI"c = [:c0, :c1, :c2, :c3] ;TI"d = a.zip(b, c) ;TI"Qd # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] ;TI" ;TI""f = {foo: 0, bar: 1, baz: 2} ;TI""g = {goo: 3, gar: 4, gaz: 5} ;TI""h = {hoo: 6, har: 7, haz: 8} ;TI"d = f.zip(g, h) ;TI"d # => [ ;TI"1 # [[:foo, 0], [:goo, 3], [:hoo, 6]], ;TI"1 # [[:bar, 1], [:gar, 4], [:har, 7]], ;TI"0 # [[:baz, 2], [:gaz, 5], [:haz, 8]] ;TI" # ] ;T:@format0o; ; [I"<If any enumerable in other_enums is smaller than self, ;TI",fills to <tt>self.size</tt> with +nil+:;T@o;; [ I"a = [:a0, :a1, :a2, :a3] ;TI"b = [:b0, :b1, :b2] ;TI"c = [:c0, :c1] ;TI"d = a.zip(b, c) ;TI"Qd # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] ;T;0o; ; [I";If any enumerable in other_enums is larger than self, ;TI"'its trailing elements are ignored:;T@o;; [ I"a = [:a0, :a1, :a2, :a3] ;TI"#b = [:b0, :b1, :b2, :b3, :b4] ;TI"(c = [:c0, :c1, :c2, :c3, :c4, :c5] ;TI"d = a.zip(b, c) ;TI"Qd # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] ;T;0o; ; [I"HWhen a block is given, calls the block with each of the sub-arrays ;TI"$(formed as above); returns nil:;T@o;; [ I"a = [:a0, :a1, :a2, :a3] ;TI"b = [:b0, :b1, :b2, :b3] ;TI"c = [:c0, :c1, :c2, :c3] ;TI"4a.zip(b, c) {|sub_array| p sub_array} # => nil ;T;0o; ; [I"Output:;T@o;; [ I"[:a0, :b0, :c0] ;TI"[:a1, :b1, :c1] ;TI"[:a2, :b2, :c2] ;TI"[:a3, :b3, :c3];T;0: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Hzip(*other_enums) -> array zip(*other_enums) {|array| ... } -> nil ;T0[ I"(*args);T@\FI"Enumerable;TcRDoc::NormalModule00