From: Tobias Reif Date: 2001-11-27T02:26:05+09:00 Subject: [ruby-talk:26530] Re: from_to, upto (recurse, yield) Paul Brannan wrote: > You are not passing a block to from_to when you call it recursively. Try > this: > > def from_to first,last,&block Thanks! This ----- def upto limit,current=0,&block yield current if not current >= limit upto limit,current.succ,&block end end upto(632) do |integer| puts integer end ----- works. But with 633, I get ----- 632 rec.rb:32:in `puts': stack level too deep (SystemStackError) from rec.rb:32 from rec.rb:31:in `upto' from rec.rb:27:in `upto' from rec.rb:27:in `upto' from rec.rb:27:in `upto' from rec.rb:27:in `upto' from rec.rb:27:in `upto' from rec.rb:27:in `upto' ... 624 levels... from rec.rb:27:in `upto' from rec.rb:27:in `upto' from rec.rb:27:in `upto' from rec.rb:31 633 ----- ruby 1.6.5 (2001-09-19) [i386-cygwin] Is there a way to prevent this in recursion? 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/