From: "Peña, Botp" Date: 2007-06-05T10:32:02+09:00 Subject: Re: Reverse-range alternatives? From: Kenneth McDonald [mailto:kenneth.m.mcdonald@sbcglobal.net] : # Since a reverse range (eg. 4...1) is functionally almost the # same as an # empty range, is there an alternative in the standard library, where # .each would actually iterate over the elements from first to last, in # this case 4, 3, 2? assumming we're all talking about range. irb(main):014:0> x => 1..4 irb(main):015:0> x.class => Range irb(main):016:0> x.last => 4 irb(main):017:0> x.first => 1 irb(main):018:0> x.last.downto x.first do |e| irb(main):019:1* p e irb(main):020:1> end 4 3 2 1 => 4 but i really hope something of a bidirectional range, ie, (4..1).to_a == [4,3,2,1] and (4..1)==(1..4).reverse, and then (4..1).each{|x| p x =>4,3,2,1 right now (4..1) is useless, but it does not _err.. kind regards -botp