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

Rather than repeat it, just refer to this thread:


Rob B.
[email protected]
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs