From: Francis Cianfrocca Date: 2006-05-22T04:50:29+09:00 Subject: Re: Array#[] and Out of Range ------=_Part_186669_56961.1148241024468 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline It makes sense. Your subscripts are ranges of indices, not indices. Ruby gives you the subarray specified by the indices in the range. In both of your examples, you get empty arrays. Were you expecting to get arrays of nils? On 5/21/06, Christoffer Sawicki wrote: > > Hello. > > I'm a bit puzzled by Array#[]'s behaviour. The documentation says > "Returns nil if the index (or starting index) are out of range." which > doesn't explain the following for me: > > (x is an arbitrary integer) > > [:x][1..x] =3D> [] > > Isn't index 1 out of range for an array with one element? > > [][0..x] =3D> [] > > Isn't index 0 out of range for an empty array? > > I could write more examples, but I hope they illustrate my point. > > Thanks, > > -- > Christoffer Sawicki > > ------=_Part_186669_56961.1148241024468--