From: sto.mar@... Date: 2013-02-24T19:04:58+09:00 Subject: Re: Confusion with `nil` value being produced by IRB in case of Array#size manipulation. Have you even tried to read the documentation??? Did you ever read any tutorial or introductory book??? Please stop posting your "experiments". *READ THE DOCS*. AGAIN: READ. THE. DOCS!!! READ. SOME. BOOK!!! Am 24.02.2013 10:45, schrieb Love U Ruby: > enum[int] = obj → obj > enum[start, length] = obj → obj > enum[range] = obj → obj > > During my reading and understandding with the above I tried something in > my IRB as below: > > a = [] > # => [] > a.size > # => 0 > > Humm, understood. As no element I still added. > > a[0] > # => nil > a[1] > # => nil > > as the array size is `0`, while trying to access the a[1] getting no > exception - why so? that means index is there or what? > what logic does help IRB to show such `nil` values? READ THE DOCS. > > a[1] = 5 > # => 5 > a > # => [nil, 5] > > The above code what should I say - new value addition or substitution of > 'nil'? READ THE DOCS. > a.size > # => 2 > > Okay! so now the size is `2`. > > Now in the below as the size is `2` thus a[3] is showing `nil`. > a[3] <~~~~ point - I > # => nil > a.size > # => 2 > > > Now I added `nil` in the same index intentionaly. And the size got > changed to `3`. OF COURSE. > a[3] = nil > # => nil > a.size > # => 3 > a[3] <~~~~ point - II > # => nil > > What is the difference between the output of a[3] in point- I and point > -II ? > Why does both `nil` value being treated differently as mentioned above? > --