From: Lyle Johnson Date: 2001-11-09T08:25:51+09:00 Subject: [ruby-talk:24708] Re: Strange behaviour of Array#[] > a = [1,2,3] > > a[2] # => 3 > a[3] # => nil > a[4] # => nil > > So far everthing is ok. > > a[3, 1] # => [] > a[4, 1] # => nil > > Why does a[3,1] returns [] instead of nil? On first glance this appears to be a bug in rb_ary_subseq() (defined in array.c). The first executable line uses this test: if (beg > RARRAY(ary)->len) return Qnil; but should probably use this instead: if (beg > RARRAY(ary)->len - 1) return Qnil; Lyle