From: Daniel Berger Date: 2005-07-22T11:00:56+09:00 Subject: Re: Odd Array#[x..y] return values Ara.T.Howard wrote: > On Fri, 22 Jul 2005, Daniel Berger wrote: > > > Hi all, > > > > Ruby 1.8.2 > > > > Consider: > > > > irb(main):001:0> a = [] > > => [] > > irb(main):002:0> a[0..1] > > => [] > > start at a legitimate index and continue with every possible index until the > end, not matter where that is > > > irb(main):003:0> a[-2..-1] > > => nil > > start at a illegitimate index and return that there cannot be anything after > this - ergo 'nil' > > > Why does the first return [] and the second return nil? > > or at least that makes sense to me... > > cheers. > > -a Please explain how one is "legitimate" and the other is not. In both cases, the indices do not exist. Regards, Dan