Re: Mutable member variables -- surprising behavior




On Apr 14, 2008, at 12:02 PM, Jason Roelofs wrote:

Eep, yeah, I forgot about that. #dup and #clone won't work, sorry for
that misinformation.

well they *might* ;-)

i've killed a lot of time over the years on that one ;-(

cheers.

a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




.



Relevant Pages

  • Re: problems with dup and clone...
    ... I have tried both dup and clone to copy the default objects but I always ... which reinitalised the instance arrays to and fix'ing the newly ... this program is a log scanner and I generate a class for each ...
    (comp.lang.ruby)
  • Re: deep cloning, how?
    ... an object, including its internal state, +dup+ typically uses the ... I *think* what it means is: clone just copies all the instance ... variables, whilst dup calls self.class.new. ... It's quite common for initialize() to have all sorts of side effects, ...
    (comp.lang.ruby)
  • Re: Bugs in Facets Cloneable?
    ... enclosing object is copied. ... a semi-deep copying version of #clone ... and #dup are in order. ... copied, not shared between duplicates. ...
    (comp.lang.ruby)
  • Re: Bugs in Facets Cloneable?
    ... sibling = self.class.new ... alias_method:dup,:clone ... shouldn't the superclass's dup be called ... def initialize_copy sibling ...
    (comp.lang.ruby)
  • Re: deep cloning, how?
    ... semantics in descendent classes. ... an object, including its internal state, +dup+ typically uses the ... I *think* what it means is: clone just copies all the instance ... variables, whilst dup calls self.class.new. ...
    (comp.lang.ruby)

Loading