HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/share/ri/2.7.0/system/Enumerator/produce-c.ri
U:RDoc::AnyMethod[iI"produce:ETI"Enumerator::produce;TT:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph;	[I"ICreates an infinite enumerator from any block, just called over and ;TI"Lover.  The result of the previous iteration is passed to the next one. ;TI"HIf +initial+ is provided, it is passed to the first iteration, and ;TI"Ibecomes the first element of the enumerator; if it is not provided, ;TI"Jthe first iteration receives +nil+, and its result becomes the first ;TI"element of the iterator.;To:RDoc::Markup::BlankLineo;
;	[I"=Raising StopIteration from the block stops an iteration.;T@o:RDoc::Markup::Verbatim;	[I"IEnumerator.produce(1, &:succ)   # => enumerator of 1, 2, 3, 4, ....
;TI"
;TI"JEnumerator.produce { rand(10) } # => infinite random number sequence
;TI"
;TI"_ancestors = Enumerator.produce(node) { |prev| node = prev.parent or raise StopIteration }
;TI"Cenclosing_section = ancestors.find { |n| n.type == :section }
;T:@format0o;
;	[I"NUsing ::produce together with Enumerable methods like Enumerable#detect, ;TI"WEnumerable#slice, Enumerable#take_while can provide Enumerator-based alternatives ;TI"$for +while+ and +until+ cycles:;T@o;;	[I"# Find next Tuesday
;TI"require "date"
;TI"?Enumerator.produce(Date.today, &:succ).detect(&:tuesday?)
;TI"
;TI"# Simple lexer:
;TI"require "strscan"
;TI"+scanner = StringScanner.new("7+38/6")
;TI"PATTERN = %r{\d+|[-/+*]}
;TI"UEnumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first
;TI"$# => ["7", "+", "38", "/", "6"];T;
0:
@fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"FEnumerator.produce(initial = nil) { |prev| block } -> enumerator
;T0[I"(p1 = v1);T@0FI"Enumerator;TcRDoc::NormalClass00