From: David Alan Black Date: 2001-01-07T02:08:38+09:00 Subject: [ruby-talk:8746] Re: (start..end) where start > end On Sun, 7 Jan 2001, Robert Gustavsson wrote: > Hi! > > Is there any reason why Ruby can't handle a "backwards" range? Oh thou of little faith! :-) > Example > --------- > num = 240 > (7..0).each do > |bitindex| > print num[bitindex] > end > print "\n" > --------- Try this: 7.downto(0) do |n| puts n end or this: (0..7).to_a.reverse.each do |n| puts n end and probably other idioms.... David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav