From: pat eyler Date: 2010-11-19T13:17:36+09:00 Subject: Re: Descending ranges in Ruby --001636b42eff98f1360495602fb4 Content-Type: text/plain; charset=ISO-8859-1 5.downto(1) { |i| puts i } 5 4 3 2 1 On Thu, Nov 18, 2010 at 9:01 PM, Harry Spier wrote: > Dear list members, > > (5..1).to_a #returns [] > (1..5).to_a #returns [1,2,3,4,5] > (5..1).each{|x| puts x} #prints (-5..-1) > (1..5).each{|x| puts x} #prints > 1 > 2 > 3 > 4 > 5 > > I don't get an error message when I declare a descending Range or when I > apply an iterator method to it, but I'm not able to iterate over a > descending Range the same way I can an ascending Range. Can someone > explain what the rationale is behind that language restriction? > > Thanks, > Harry > > -- > Posted via http://www.ruby-forum.com/. > > -- thanks, -pate ------------------------- Don't judge those who choose to sin differently than you do --001636b42eff98f1360495602fb4--