From: Robert Klemme Date: 2008-10-16T23:59:35+09:00 Subject: Re: what is [] here On 16.10.2008 16:13, Serabe wrote: > 2008/10/16 Raj Singh : >> What does it mean to have [] method at a class level? Where is the >> documentation for it? > > It is the empty array. Just type > > [].class => Array > [].size => 0 It is not _the_ empty Array but _an_ empty Array. Things like [], "" and '' are actually constructors for new objects. This is important to keep in mind. Especially people coming from Java might get the wrong impression, that a = "foo" b = "foo" will create two variables pointing to the same object. In reality, there are two variables pointing to two different objects. You can easily see that from $ ruby -e '4.times do p [[],"",'\'\''].map {|o|o.object_id} end' [134314000, 134313990, 134313980] [134313890, 134313880, 134313870] [134313790, 134313780, 134313770] [134313690, 134313680, 134313670] Kind regards robert