On Sep 8, 2011, at 4:08 AM, Adam Prescott wrote:

> There's discussion about this at =
http://www.ruby-forum.com/topic/1393096

Gary Wright's explanation in the thread linked above is very complete =
and clear.
Strongly recommended if you are at all foggy on this topic.

I will add one terminology/memory tidbit -

The difference in the one-arg/two-arg indexing is ruby's way of dealing =
with
the classic fence post problem. (i.e. A fence with 3 sections has 4 =
posts.)

One-arg (e.g. a[1]) -- The argument addresses "fence sections".
Two-arg (e.g. a[1,2]) -- The first argument addresses "fence posts".

(As others have pointed out already, there are reasons for doing both
things from time to time.)

So, to answer the original question using "fence" terminology -

> array =3D [:peanut, :butter, :and, :jelly]
> ...
> array[4,0]     =3D> []     # why is this an empty array and not nil?
and
> array[5,0]     =3D> nil    # as expected

because there is a "post" at 4 and not at 5.

Dan Nachbar