On Dec 28, 3:54 am, [email protected] (Jeff Peng) wrote:
> Uri Guttman:
>
>
>
> > and i bet you really don't need this but you just think you do.
>
> why not?
> I did have used object clone, like a ruby one:
>
> > class Myclass
> > end
> => nil
>
> > x=Myclass.new
> => #<Myclass:0xb7c4bca8>
>
> > y=x.clone
> => #<Myclass:0xb7c47194>
>
> > x.object_id
> => -605921708
>
> > y.object_id
> => -605931318
>
> The object was cloned, they both got different object IDs.
<off-topic> But, Ruby's clone method does a shallow copy so
instance variables can get clobbered -- likely
not
the behavior you want. From RDoc:
obj.clone → an_object
Produces a shallow copy of obj—the instance
variables of obj
are copied, but not the objects they
reference. ...
</off-topic>
--
Charles DeRykus
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/