From: sur max Date: 2007-03-15T04:05:54+09:00 Subject: Re: Where is my Class ? ------=_Part_32178_5406542.1173899149900 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Pit, Thanks a lot for explaining. On 3/14/07, Pit Capitain wrote: > > sur max schrieb: > > (...) > > B=a # warning: already initialized constant B > > (...) > > this means that the Class B is overwritten by the Class referenced by > "a" > > so it is the case of changing a constant. Is that possible ? > > No, no objects are overwritten in Ruby. An assignment like > > var = obj > > just makes the object on the right (obj) accessible via the name on the > left (var). The line > > B = a > > makes the object referenced by a (the anonymous class) accessible via > the name B. After this, a and B are different names for the same object. > The previous object referenced by the name B is still around (until the > garbage collector reclaims it) and not changed at all. > > In Ruby, constants, instance, and local variables are only names for > objects. Constants have the additional property that they are intended > to be assigned to only once. If you re-assign a constant, you get a > warning, but the assignment happens nonetheless. Try this with something > different than anonymous classes and it might be easier to understand. > > There have been many discussions about variable names and objects on > this mailing list. You can also look at > > http://onestepback.org/index.cgi/Tech/Ruby/Shoeboxes.rdoc > > Regards, > Pit > > -- sur "is a String object" is a String object http://expressica.com ------=_Part_32178_5406542.1173899149900--