On Tue, Feb 1, 2011 at 8:01 AM, Josh Cheek <josh.cheek / gmail.com> wrote:
> On Tue, Feb 1, 2011 at 12:51 AM, Stefano Grioni <stefano.grioni / epfl.ch>wrote:
>
>> Can anyone explain me why this strange behavior is implemented as such,
>> and how can I circle that without the need to use the very ugly
>> 1..4).each { |i| p (4-i) } ?
>>
> 4.downto(1) { |i| p i }

This is certainly the most efficient variant.  For the general case
there is Enumerable#reverse_each - at least from 1.8.7 on.  Since it's
implemented in Range as well I guess this will be efficient, too.

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/