D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Array
/
Filename :
cycle-i.ri
back
Copy
U:RDoc::AnyMethod[iI" cycle:ETI"Array#cycle;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"YWith a block given, may call the block, depending on the value of argument +count+; ;TI"+count+ must be an ;TI"b{integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects], ;TI"or +nil+.;To:RDoc::Markup::BlankLine o; ; [I"When +count+ is positive, ;TI"Acalls the block with each element, then does so repeatedly, ;TI"7until it has done so +count+ times; returns +nil+:;T@o:RDoc::Markup::Verbatim; [I"output = [] ;TI"@[0, 1].cycle(2) {|element| output.push(element) } # => nil ;TI"output # => [0, 1, 0, 1] ;T:@format0o; ; [I"?When +count+ is zero or negative, does not call the block:;T@o;; [I"A[0, 1].cycle(0) {|element| fail 'Cannot happen' } # => nil ;TI"A[0, 1].cycle(-1) {|element| fail 'Cannot happen' } # => nil ;T; 0o; ; [I"+When +count+ is +nil+, cycles forever:;T@o;; [I"# Prints 0 and 1 forever. ;TI",[0, 1].cycle {|element| puts element } ;TI"1[0, 1].cycle(nil) {|element| puts element } ;T; 0o; ; [I"3With no block given, returns a new Enumerator.;T@o; ; [I"PRelated: see {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].;T: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"Ucycle(count = nil) {|element| ... } -> nil cycle(count = nil) -> new_enumerator ;T0[ I"(*args);T@1FI" Array;TcRDoc::NormalClass00