From: Li Chen Date: 2009-06-24T02:32:46+09:00 Subject: Re: Is it the ruby way to implement #downto Skye Shaw!@#$ wrote: > Well, I'd hope that creating 3 unnecessary objects wouldn't be deemed > the Ruby way :^) > Most code I've seen would use each() instead of for i in (). Each is > faster anyways. I do it this way using each(). def my_downto2(final=2) (final..self).to_a.reverse.each do |i| yield i end end But I am still uncomfortable that I have to use #to_a followed by #reverse to do the trick. Besides using while loops what is the best way to add a new method of #downto? Thanks, Li -- Posted via http://www.ruby-forum.com/.