D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerable
/
Filename :
each_cons-i.ri
back
Copy
U:RDoc::AnyMethod[iI"each_cons:ETI"Enumerable#each_cons;TF:publico:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Paragraph; [I"LCalls the block with each successive overlapped +n+-tuple of elements; ;TI"returns +self+:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [ I"a = [] ;TI"6(1..5).each_cons(3) {|element| a.push(element) } ;TI".a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] ;TI" ;TI"a = [] ;TI"+h = {foo: 0, bar: 1, baz: 2, bam: 3} ;TI"1h.each_cons(2) {|element| a.push(element) } ;TI"Ua # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] ;T:@format0o; ; [I"0With no block given, returns an Enumerator.;T: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Geach_cons(n) { ... } -> self each_cons(n) -> enumerator ;T0[ I" (p1);T@FI"Enumerable;TcRDoc::NormalModule00