Help with array

I’m working through the rubykoans and I cannot figure out one of them.

array = [1, 2, 3, 4]

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

From RDoc:
Returns nil if the index (or starting index) are out of range.

That means array[4,0] would return nil, right?

Thanks for the help.

On Oct 18, 2010, at 4:29 PM, Matthew Boston wrote:

Thanks for the help.


Posted via http://www.ruby-forum.com/.

Rather than repeat it, just refer to this thread:
Arraystrange behaviour - Ruby - Ruby-Forum

-Rob

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/