From: Tobias Reif Date: 2001-11-27T01:51:27+09:00 Subject: [ruby-talk:26528] from_to, upto (recurse, yield) Hi; this works: ----- def from_to first,last current = first yield current if not current >= last from_to current.succ,last end end from_to(3,4) do |integer| print integer.to_s + "\n" end ---gives--- 3 4 ----- This doesn't: ----- def from_to first,last current = first yield current if not current >= last from_to current.succ,last end end from_to(3,5) do |integer| print integer.to_s + "\n" end ---gives--- 3 4 rec.rb:14:in `from_to': yield called out of block (LocalJumpError) from rec.rb:16:in `from_to' from rec.rb:16:in `from_to' from rec.rb:20 ----- Why? same with --- def upto limit, current=0 yield current if not current >= limit upto limit,current.succ end end upto(1) do |integer| print integer.to_s + "\n" end --- ; works with 1, but not with 2. Tobi ruby 1.6.5 (2001-09-19) [i386-cygwin] -- 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/