On Thu, Oct 07, 2004 at 02:06:24AM +0900, trans.  (T. Onoma) wrote:
> On Wednesday 06 October 2004 06:16 am, Brian Candler wrote:
> | (FWIW, these ranges annoy me: firstly because they're not ranges, and
> | secondly because I can never remember the difference between a[2..4] versus
> | a[2,4], and I write a[2,-1] when I should write a[2..-1]. I have to make
> | test cases in irb every time!)
> 
> Agreed. I doubt they are ever used. I don't even consider them. Obfuscation 
> pure and simple.

Is there an easier way to say "give me all the elements of this
(string/array) from position P to the end"?

    str[p, str.size-p]

is not particularly nice. Allowing Infinity for the second parameter might
be nice though :-)

Also, occasionally I've wanted "give me every element apart from the last
one": again,

   str[0, str.size-1]

isn't pretty. I suppose str[0..-2] is more compact but more obscure.

Cheers,

Brian.