Beginner to RUBY - Array Question
Posted
by WANNABE
on Stack Overflow
See other posts from Stack Overflow
or by WANNABE
Published on 2010-04-22T09:15:19Z
Indexed on
2010/04/22
9:23 UTC
Read the original article
Hit count: 290
a = [ 1, 3, 5, 7, 9 ] ? [1, 3, 5, 7, 9]
a[2, 2] = ’cat’ ? [1, 3, "cat", 9]
a[2, 0] = ’dog’ ? [1, 3, "dog", "cat", 9]
a[1, 1] = [ 9, 8, 7 ] ? [1, 9, 8, 7, "dog", "cat", 9]
a[0..3] = [] ? ["dog", "cat", 9]
a[5..6] = 99, 98 ? ["dog", "cat", 9, nil, nil, 99, 98]
I can understand how the last four amendments to this array work, but why do they use a[2, 2] = 'cat' and a[2,0] = 'dog' ???
What do the two numbers represent?
Couldnt they just use a[2] = 'dog'?
© Stack Overflow or respective owner