From: Hal Fulton Date: 2003-12-14T23:33:49+09:00 Subject: Re: inplace assignment nobu.nokada@softhome.net wrote: > Hi, > > At Sun, 14 Dec 2003 15:50:54 +0900, > Hal Fulton wrote: > >>>>In other words I want to change what q "contains" rather then alter its >>>>reference. With an array for example you can do that with #replace. In >>>>particular I'm interesed in doing this with constants. >>> >>> >>>Array#replace isn't concerned with constants. >>> >>> A = [1] >>> A.replace([2]) >>> p A[0] # => 2 >> >>Thanks for pointing this out. I don't think I ever noticed that. >> >>Should this give an error? > > > No. A constant in Ruby is a name which can point to only > particular object. Nothing related to the container's > contents. > Actually, I completely misread your example. I already understood this phenomenon. I thought that the assignment was silently discarded, i.e., I read this as: A = [1] A.replace([2]) p A[0] # => 1 Sorry for being stupid. :) Hal