summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-21 13:54:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-21 13:54:31 +0000
commite12df5ef40ff52d7428e89048c2424b57e26a907 (patch)
treef261acbf1384347a0f63f3026adba395a70b0167 /enumerator.c
parent3188b4695b917781563d72580943de8675072142 (diff)
Update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c18
1 files changed, 18 insertions, 0 deletions
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