From: Daniel Berger Date: 2009-08-05T15:27:08+09:00 Subject: Re: Bizarre Range behavior > -----Original Message----- > From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org] > Sent: Tuesday, August 04, 2009 10:56 PM > To: ruby-talk ML > Subject: Re: Bizarre Range behavior > > Hi, > > In message "Re: Bizarre Range behavior" > on Wed, 5 Aug 2009 05:32:37 +0900, Rob Biedenharn > writes: > > |Knowing this, here's an even more bizzare-looking example: > | > |irb> "19".succ > |=> "20" > |irb> ("2".."19").to_a > |=> [] > |irb> ("2"..."20").to_a > |=> ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", > |"14", "15", "16", "17", "18", "19"] > > What if I sprinkle more magic to the language and change String#upto > to generate numerical sequences when all characters in edges are > digits, so that > > irb> ("2".."19").to_a > => ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", > "14", "15", "16", "17", "18", "19"] > irb> ("2"..."20").to_a > => ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", > "14", "15", "16", "17", "18", "19", "20"] > > Any opinion? I already made a patch for trunk. I vote against. If people want numeric ranges, it's their job to use numerics, not magically convert stringy numbers into actual numbers. This isn't Perl after all. Regards, Dan