From: Michal Suchanek Date: 2007-12-31T01:35:30+09:00 Subject: Re: RCR allow indexing last n items On 30/12/2007, David A. Black wrote: > Hi -- > > On Sun, 30 Dec 2007, Michal Suchanek wrote: > > > Hello > > > > As discussed in thread starting with ruby-talk # 284001 there is an > > inconsistency in handling positive and negative range indexes to > > arrays and strings. > > > > Currently the requirement is that the first number in the range does > > fall into the string. > > > > This allows "asd'[0...10] to return the first (at most) 10 characters > > of the string. > > > > However, the same cannot be done on the end: > > > > "asd"[-10..-1] returns nil even though this could mean the last (at > > most) 10 characters as direct opposite of the above. However, the > > first number (-10) yields an index length-10 = -7 which is outside of > > the string. > > > > To make it possible to index the end of the string as easily as the > > beginning the rules for indexing should be changed slightly. > > I'd rather not have the index magically converted. I don't think I can > come up with an airtight technical reason. It just seems a bit > over-engineered; I'd prefer for -10 to mean -10 from the right. I want -10 to mean 10 from the right as it does now. I just want the bounds checking to be the same when counting from the right as it is when counting from the left. > > > I would submit this to rcrchive but for some reason I cannot sign up for it. > > I just submitted your confirmation string, and it registered you. Did > you never get the confirmation email? > > > David > Yes, never got it. It happens for me with some email registrations. Thanks Michal