(enumerator_next): call ary2sv with dup=0.
(enumerator_peek): call ary2sv with dup=1 to return duplicated array.
(enumerator_peek_values_m): new function to return duplicated array.
(Init_Enumerator): use enumerator_peek_values_m as
Enumerator#peek_value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and StopIteration#result. [ruby-dev:39109]
(struct enumerator): replace no_next by stop_exc.
new field feedvalue.
(enumerator_mark): mark feedvalue and stop_exc.
(enumerator_init): initialize feedvalue and stop_exc.
(enumerator_init_copy): initialize feedvalue.
(next_ii): send yield arguments as an array. return feedvalue.
(next_i): generate StopIteration exception here. set result.
(next_init): initialize feedvalue.
(enumerator_next_values): new method Enumerator#next_values.
(ary2sv): new function.
(enumerator_peek_values): new method Enumerator#peek_values.
(enumerator_feed): new method Enumerator#feed.
(yielder_yield): return the yield value.
(generator_each): return the iterator value.
(stop_result): new method StopIteration#result.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
test/ruby/test_enumerator.rb: Add an ability to generate an
enumerator from a block. [experimental] [ruby-dev:35903]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
test/readline/test_readline_history.rb (Readline#test_each__enumerator),
test/ruby/test_array.rb (TestArray#test_collect),
test/ruby/test_enumerator.rb (TestEnumerator#test_initialize):
Enumerable::Enumerator is now called Enumerator.
* lib/rinda/tuplespace.rb (Rinda::TupleBag#initialize): Use
enum_for instead of hardcoding Enumerable::Enumerator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
the end of each block. [ruby-dev:31470]
* enumerator.c (enumerator_next_p): call init_next if not
initialized. [ruby-dev:31514]
* test/ruby/test_enumerator.rb: add tests for Enumerator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e