D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerator
/
Lazy
/
Filename :
enum_for-i.ri
back
Copy
U:RDoc::AnyMethod[iI" enum_for:ETI"Enumerator::Lazy#enum_for;TF:publico:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Paragraph; [I"ESimilar to Object#to_enum, except it returns a lazy enumerator. ;TI"?This makes it easy to define Enumerable methods that will ;TI"<naturally remain lazy if called from a lazy enumerator.;To:RDoc::Markup::BlankLine o; ; [I"@For example, continuing from the example in Object#to_enum:;T@o:RDoc::Markup::Verbatim; [ I"7# See Object#to_enum for the definition of repeat ;TI"r = 1..Float::INFINITY ;TI"/r.repeat(2).first(5) # => [1, 1, 2, 2, 3] ;TI"'r.repeat(2).class # => Enumerator ;TI"=r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop! ;TI"+# works naturally on lazy enumerator: ;TI"2r.lazy.repeat(2).class # => Enumerator::Lazy ;TI"Cr.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9];T:@format0: @fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below000[ I"(*args);T@FI" Lazy;TcRDoc::NormalClass0[I"Enumerator::Lazy;TFI"to_enum;T