1
0
Fork 0
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:
akr 2013-05-21 13:54:31 +00:00
parent 3188b4695b
commit e12df5ef40

View file

@ -819,6 +819,24 @@ enumerator_peek(VALUE obj)
*
* 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
* def o.each
* x = yield # (2) blocks