From: Jim Freeze Date: 2004-02-26T04:21:20+09:00 Subject: Re: Slice or Value of Empty Array On Thursday, 26 February 2004 at 3:56:57 +0900, Austin Ziegler wrote: > On Thu, 26 Feb 2004 03:34:03 +0900, Jim Freeze wrote: > > Hi > > I am puzzling about the following: > (reformatted) > > p [][0..0] # => [] > p [][0..-1] # => [] > p [][-1..-1] # => nil > > > If ary[n..n] returns a slice, then why does a[0..0] give me an > > empty array and a[-1..-1] give me nil? > > Matz explained this some time ago. I think it has something to do > with indexes sitting *between* elements in Ruby arrays, and the last > element being precached as empty. > > I'm not sure if that makes any sense... Hmm, vaguely. Do you have the reference? -- Jim Freeze Philosophy will clip an angel's wings. -- John Keats