From: David Alan Black Date: 2004-05-09T04:13:57+09:00 Subject: Re: How to get the last 5 elements of an array? Hi -- Gavin Sinclair writes: > For example, consider this: > > x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > x[-5..3] # -> nil > > If even *that* returns nil, when *all* numbers in the range are valid > indexes, then... > > Also, there's everybody's favourite example: > > x[10..15] # -> [] > x[11..15] # -> nil > > I'd rather see 'arr[range]' *always* return an array, no matter the > value of 'arr' and 'range'. I guess it comes down to the necessity to translate between the very different perspectives of Arrays and Ranges when it comes to counting. For example, for a 5-element array, -3 > 1, counting Array-style. I don't know whether there's a way to un-anomalize it; it may be one of these lumps that can be moved around under the carpet but is still always somewhere. David -- David A. Black dblack@wobblini.net