From: Rick DeNatale Date: 2009-08-06T01:21:24+09:00 Subject: Re: Bizarre Range behavior On Wed, Aug 5, 2009 at 12:12 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Bizarre Range behavior" >    on Thu, 6 Aug 2009 00:35:41 +0900, Rob Biedenharn writes: > > |I'd actually prefer *less* magic here. (And I hope that your second > |example with "2"..."20" wouldn't include "20" since the range excludes > |its end.) > > May bad for the error in the example.  It wouldn't include "20" in the > actual code. > > |The surprising aspect is that the Range#to_a can give an array that > |has just the #begin. String#upto perhaps needs more magic to know that > |#succ will eventually work ("9".upto("10") as well as > |"cat".upto("bird")) > > We have to define the "magic" behavior first, but I love magic if we > can make specific definition. This particular magic I don't like, since it would treat strings as strings sometimes and numbers otherwise. I'm in agreement with David A. Black here. If anything should be changed here, IMHO, it would be addressing Rob's surprise (which I share) that ("100.."11") produces ["100"] instead of ["100", "101", "102", "103", "104", "105", "106", "107", "108", "109"] i.e. I'd expect it to act as if it used the succ and comparison methods. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale