ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: Cloning into an object
by Charles Steinman other posts by this author
Apr 30 2005 8:05PM messages near this date
Cloning into an object | [OT] Trouble trying Tao - myriards of compile errors :-<
Eric Mahurin wrote:
>  Anybody know how to generically copy (shallow like clone) an
>  object into another object?  It would be nice to handle the
>  case where the objects have a different class, but I would at
>  least like to know how to do it when the classes are the same.
> 
>  Here is an example of what I would like to do:
> 
>  dest = Object.new # or String.new if necessary
>  source = "hello world"
>  destid = dest.id
> 
>  source.clone_into(dest)
> 
>  dest             -> "hello world"
>  dest.id==destid  -> true
>  dest.class       -> String

Is the only difference between this and Object#clone that the object_id
is the same as the old object's? Because that's all I can see here, but
I don't understand why that would come in handy.
Thread:
Eric Mahurin
Charles Steinman

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved