mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3188b4695b
commit
e12df5ef40
1 changed files with 18 additions and 0 deletions
18
enumerator.c
18
enumerator.c
|
@ -819,6 +819,24 @@ enumerator_peek(VALUE obj)
|
||||||
*
|
*
|
||||||
* This value is cleared after being yielded.
|
* This value is cleared after being yielded.
|
||||||
*
|
*
|
||||||
|
* # Array#map passes the array's elements to "yield" and collects the
|
||||||
|
* # results of "yield" as an array.
|
||||||
|
* # Following example shows that "next" returns the passed elements and
|
||||||
|
* # values passed to "feed" are collected as an array which can be
|
||||||
|
* # obtained by StopIteration#result.
|
||||||
|
* e = [1,2,3].map
|
||||||
|
* p e.next #=> 1
|
||||||
|
* e.feed "a"
|
||||||
|
* p e.next #=> 2
|
||||||
|
* e.feed "b"
|
||||||
|
* p e.next #=> 3
|
||||||
|
* e.feed "c"
|
||||||
|
* begin
|
||||||
|
* e.next
|
||||||
|
* rescue StopIteration
|
||||||
|
* p $!.result #=> ["a", "b", "c"]
|
||||||
|
* end
|
||||||
|
*
|
||||||
* o = Object.new
|
* o = Object.new
|
||||||
* def o.each
|
* def o.each
|
||||||
* x = yield # (2) blocks
|
* x = yield # (2) blocks
|
||||||
|
|
Loading…
Add table
Reference in a new issue