D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerable
/
Filename :
cycle-i.ri
back
Copy
U:RDoc::AnyMethod[iI" cycle:ETI"Enumerable#cycle;TF:publico:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Paragraph; [I"AWhen called with positive integer argument +n+ and a block, ;TI"<calls the block with each element, then does so again, ;TI"3until it has done so +n+ times; returns +nil+:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"a = [] ;TI";(1..4).cycle(3) {|element| a.push(element) } # => nil ;TI"1a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] ;TI"a = [] ;TI"6('a'..'d').cycle(2) {|element| a.push(element) } ;TI"5a # => ["a", "b", "c", "d", "a", "b", "c", "d"] ;TI"a = [] ;TI"D{foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } ;TI"Oa # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] ;T:@format0o; ; [I";If count is zero or negative, does not call the block.;T@o; ; [I"?When called with a block and +n+ is +nil+, cycles forever.;T@o; ; [I"3When no block is given, returns an Enumerator.;T: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Zcycle(n = nil) {|element| ...} -> nil cycle(n = nil) -> enumerator ;T0[ I"(*args);T@%FI"Enumerable;TcRDoc::NormalModule00