Why no decreasing enumerations?

If you actually have to do this task all the time, you could define your
own Integer#to method:

···

####
class Integer

  def to limit, &block
    if self <= limit
      upto limit, &block
    else
      downto limit, &block
    end
  end

end

10.to 1 do |i|
  puts i
end
####

I wonder why *that* isn't already in Ruby. :wink:

--
Posted via http://www.ruby-forum.com/.

Have you proposed it to ruby-core@?

···

On Mar 18, 2012, at 22:09 , Jan E. wrote:

class Integer

def to limit, &block
   if self <= limit
     upto limit, &block
   else
     downto limit, &block
   end
end

end

10.to 1 do |i|
puts i
end
####

I wonder why *that* isn't already in Ruby. :wink:

Is this in Facets?

···

On Mon, Mar 19, 2012 at 02:09:08PM +0900, Jan E. wrote:

10.to 1 do |i|
  puts i
end
####

I wonder why *that* isn't already in Ruby. :wink:

--
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]

This is a feature I've implemented several times myself as well and would seem to be useful to have in core. Ryan, what is the recommended way of making these proposals? Just post a message to the ruby-core mailing list? Open a ticket? Do we still have some sort of RCRchive?

It's been a while since I've asked for something in Ruby :slight_smile:

-greg

···

On 3/19/12 7:28 AM, Ryan Davis wrote:

On Mar 18, 2012, at 22:09 , Jan E. wrote:

class Integer

  def to limit,&block
    if self<= limit
      upto limit,&block
    else
      downto limit,&block
    end
  end

end

10.to 1 do |i|
  puts i
end
####

I wonder why *that* isn't already in Ruby. :wink:

Have you proposed it to ruby-core@?