```David,

Ahh, now I get it! Your explanation shows this is simpler to grasp than I
thought; my brain made it more complex!!

Thanks much....

-----Original Message-----
From: David Alan Black [mailto:dblack / candle.superlink.net]
Sent: Thursday, October 25, 2001 6:37 PM
To: ruby-talk ML
Subject: [ruby-talk:23368] Re: Paired Arrays

Hello --

On Fri, 26 Oct 2001, Cliff Urr wrote:

> I am a rank newbie - trying to learn Ruby (my 1rst language). The Ruby
book
> says in this example about arrays:

Welcome, nuby!

> "You can also index arrays with a pair of numbers, [start, count]. This
> returns a new array
> consisting of references to count objects starting at position start.
>
>  a = [ 1, 3, 5, 7, 9 ]
>  a[1, 3] > [3, 5, 7]
>  a[3, 1]  > [7]
>  a[-3, 2] > [5, 7]"
>
> I don't get why the last line above results in [5,7]  Isn't this an error,
> becuase shouldn't it be:
>
> a[-3,2] > [5,7,9]
>
> If you count the negative number from the last one, which gets you to
where
> "5" is, then count up to 2 places after that, should it not include not
only
> 7 but 9 also?

The first number (-3) is the starting index, and the second number (2) is
the
number of elements to return.  So the first returned element is a[-3], and
the second is a[-2] -- and that's all.

David

--
David Alan Black