ruby-changes:19833
From: ryan <ko1@a...>
Date: Wed, 1 Jun 2011 08:21:30 +0900 (JST)
Subject: [ruby-changes:19833] ryan:r31879 (trunk): Extra formatting and clarification of enumerator_feed [#4757]
ryan 2011-06-01 08:19:50 +0900 (Wed, 01 Jun 2011) New Revision: 31879 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31879 Log: Extra formatting and clarification of enumerator_feed [#4757] Modified files: trunk/enumerator.c Index: enumerator.c =================================================================== --- enumerator.c (revision 31878) +++ enumerator.c (revision 31879) @@ -714,26 +714,30 @@ * call-seq: * e.feed obj -> nil * - * Set the value to be returned by the next call to +yield+ by the enumerator. - * If the value is not set, the +yield+ returns +nil+ and the value is cleared - * after it is used the first time. + * Set the value for the next yield in the enumerator returns. * - * +obj+:: the object to return from the next call to the Enumerator's +yield+ + * If the value is not set, the yield returns nil. * - * === Example + * This value is cleared after being used. * - * three_times = Enumerator.new do |yielder| - * 3.times do |x| - * result = yielder.yield(x) - * puts result - * end + * o = Object.new + * def o.each + * x = yield # (2) blocks + * p x # (5) => "foo" + * x = yield # (6) blocks + * p x # (8) => nil + * x = yield # (9) blocks + * p x # not reached w/o another e.next * end * - * three_times.next # => 0 - * three_times.feed("foo") - * three_times.next # => 1, prints "foo" - * three_times.next # => 2, prints nothing + * e = o.to_enum + * e.next # (1) + * e.feed "foo" # (3) + * e.next # (4) + * e.next # (7) + * # (10) */ + static VALUE enumerator_feed(VALUE obj, VALUE v) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/