Array behaviour - referencing past last element

I find this a bit strange:

irb(main):001:0> a=[1,2,3]
=> [1, 2, 3]
irb(main):002:0> a[2,1]
=> [3]
irb(main):003:0> a[3,1]
=> []
irb(main):004:0> a[4,1]
=> nil

Both a[3,1] and a[4,1] use out of range indices, so why is there a difference?

(Sorry if this has come up before, I searched but could not find)

Stephen
± S.D.Sykes - http://www.stephensykes.com

Both a[3,1] and a[4,1] use out of range indices, so why is there a
difference?

The explanantion is given in [ruby-talk:24786]

http://www.ruby-talk.org/24786

Guy Decoux