From: "Guy N. Hurst" Date: 2001-01-07T05:04:43+09:00 Subject: [ruby-talk:8758] Re: (start..end) where start > end David Alan Black wrote: > > On Sun, 7 Jan 2001, Robert Gustavsson wrote: > > > >> (7..0).each do > > > > >Try this: > > > 7.downto(0) do |n| puts n end > > > (0..7).to_a.reverse.each do |n| puts n end > > > > Do you agree with me when I say that (7..0) is more beautiful? And it would > > probably be more efficient too. > > It's certainly more beautiful than the to_a.reverse version. I don't > mind #downto too much -- though (7..0) would be nice. I wonder if > there's something inherent in the definition of a range (as opposed to > an array) which precludes that. > This leads into the discussion (again ;-) about #succ and why there isn't something like #pred etc. If someone came up with a good algorithm/method to do the inverse of #succ, I think matz would be willing to talk about it. cf. [ruby-talk:5868] Guy N. Hurst -- HurstLinks Web Development http://www.hurstlinks.com/ Norfolk, VA 23510 (757)623-9688 FAX 623-0433 PHP/MySQL - Ruby/Perl - HTML/Javascript