From e12df5ef40ff52d7428e89048c2424b57e26a907 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 21 May 2013 13:54:31 +0000 Subject: [PATCH] Update doc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enumerator.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/enumerator.c b/enumerator.c index a5f675e8ef..54fa49ff3c 100644 --- a/enumerator.c +++ b/enumerator.c @@ -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