Help with array

M

Matthew Boston

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.
 
R

Rob Biedenharn

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.


Rather than repeat it, just refer to this thread:
http://www.ruby-forum.com/topic/216796

-Rob

Rob Biedenharn
(e-mail address removed) http://AgileConsultingLLC.com/
(e-mail address removed) http://GaslightSoftware.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,629
Members
45,329
Latest member
InezZ76898

Latest Threads

Top