Forum: Ruby Accessing array by slicing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
21cb9b23398a37fc04850a17c2a6ba5d?d=identicon&s=25 Roy Browne (rubymore)
on 2017-03-20 14:09
Question?

array = [A,B,C,D]

array[1]  => B
array[3] => D

array[1,2] => [B,C]
array[0,3] => [A,B,C]

Why does array[4,0] return [], yet array[5,0] returns nil?

Both should be out of bounds.
This topic is locked and can not be replied to.