From: Austin Ziegler Date: 2004-02-26T03:56:57+09:00 Subject: Re: Slice or Value of Empty Array 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... -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2004.02.25 * 13.53.09