M
Mikel Lindsaar
Hi all,
Running Ruby 1.8.7. And I saw Jim Weirich's post about the Ruby Koans, =
and I thought, what the hey! Lets do them!
So I downloaded, and what do you know! I found something I didn't =
understand!!
Anyway, per http://ruby-doc.org/core/classes/Array.html#M002205 it says: =
"Returns nil if the index (or starting index) are out of range".
So given array:
array =3D [eanut, :butter, :and, :jelly]
One would expect:
array[4] =3D=3D nil #=3D> true
array[5] =3D=3D nil #=3D> true
Which works, 4 and 5 are both out of range.
However:
array[4,0] =3D=3D nil #=3D> false
array[5,0] =3D=3D nil #=3D> true
Huh? In actual fact array[4,0] returns an empty array. This seems in =
conflict with the docs.
Can someone more enlightened please explain?
Thank you!
Mikel
Running Ruby 1.8.7. And I saw Jim Weirich's post about the Ruby Koans, =
and I thought, what the hey! Lets do them!
So I downloaded, and what do you know! I found something I didn't =
understand!!
Anyway, per http://ruby-doc.org/core/classes/Array.html#M002205 it says: =
"Returns nil if the index (or starting index) are out of range".
So given array:
array =3D [eanut, :butter, :and, :jelly]
One would expect:
array[4] =3D=3D nil #=3D> true
array[5] =3D=3D nil #=3D> true
Which works, 4 and 5 are both out of range.
However:
array[4,0] =3D=3D nil #=3D> false
array[5,0] =3D=3D nil #=3D> true
Huh? In actual fact array[4,0] returns an empty array. This seems in =
conflict with the docs.
Can someone more enlightened please explain?
Thank you!
Mikel