From: Tobias Reif Date: 2001-11-30T02:24:40+09:00 Subject: [ruby-talk:26940] Re: short article draft for review David, > def my_iterator > i = 0 > while i < 10 > yield i * 2 > i += 1 > end > end > > my_iterator do |result| > print "Next result is: " > puts result > end Thank you very much for your feedback! The first example uses an iterator, the second one implements one. The implementation uses recursion, and thus passes the block. I think it makes sense to leave both in: the first one is very simple, and the second one shows blocks and arguments, and recursion. I see your point of including a simple implementation of an iterator, without recursion, and thus without passing blocks. I built an example from your snippet: ----- def upto limit,modifier='default' if modifier == 'even' number = 2 step = 2 elsif modifier == 'odd' number = 1 step = 2 else number = 1 step = 1 end while number <= limit yield number number += step end end upto 5 do |number| puts number end upto 5,'even' do |number| puts number end upto 5,'odd' do |number| puts number end ----- but the article is very short, and I don't want to feature three examples for iterators, two of them implementing one. Thanks again, Tobi -- Tobias Reif http://www.pinkjuice.com/myDigitalProfile.xhtml go_to('www.ruby-lang.org').get(ruby).play.create.have_fun http://www.pinkjuice.com/ruby/