From: "Thomas B." Date: 2008-10-20T02:01:16+09:00 Subject: Re: prob with ranges Junkone wrote: > so i cannot have a range that is decreasing in numbers. for eg > 1..5 can be 1,2,3,4,5 > how can i do 5..1 ie 5,4,3,2,1 Range is by definition increasing. If you want to iterate over numbers from 5 to 1, you can do it like this: (1..5).to_a.reverse.each or better (1..5).to_a.reverse_each (this does not allocate the reversed array, just iterates in the opposite order). Both these methods allocate the array of all the values, though, so if your range is big, you should probably use an explicit loop with a decremented value and a stop condition. TPR. -- Posted via http://www.ruby-forum.com/.