[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Deep Clone of array?

Ronald Fischer

8/9/2007 8:13:00 AM

Is there a standard way of doing a deep copy of an object (in
particular, of an array)?

http://www.ruby-doc.org/core/classes/Object.ht... mentions a
function 'dclone',
but this doesn't seem to exist:

undefined method `dclone'
--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162

4 Answers

Robert Klemme

8/9/2007 8:27:00 AM

0

2007/8/9, Ronald Fischer <ronald.fischer@venyon.com>:
> Is there a standard way of doing a deep copy of an object (in
> particular, of an array)?

copy_of_your_array = Marshal.load(Marshal.dump(your_array))

> http://www.ruby-doc.org/core/classes/Object.ht... mentions a
> function 'dclone',
> but this doesn't seem to exist:
>
> undefined method `dclone'

I've never seen that method. No idea.

Kind regards

robert

Ken Bloom

8/9/2007 2:08:00 PM

0

On Thu, 09 Aug 2007 17:13:09 +0900, Ronald Fischer wrote:

> Is there a standard way of doing a deep copy of an object (in
> particular, of an array)?
>
> http://www.ruby-doc.org/core/classes/Object.ht... mentions a
> function 'dclone',
> but this doesn't seem to exist:
>
> undefined method `dclone'

It's annoying -- the ruby-doc core documentation includes all of the
standard library, so it's hard to tell what comes from where. (Perhaps
they can regenerate the documentation?)

Anyway, if you click on the function name, you'll see the source code:

# File lib/rexml/xpath_parser.rb, line 8
def dclone
clone
end


--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

Ken Bloom

8/9/2007 2:08:00 PM

0

On Thu, 09 Aug 2007 17:13:09 +0900, Ronald Fischer wrote:

> Is there a standard way of doing a deep copy of an object (in
> particular, of an array)?
>
> http://www.ruby-doc.org/core/classes/Object.ht... mentions a
> function 'dclone',
> but this doesn't seem to exist:
>
> undefined method `dclone'

Marshal.load(Marshsl.dump(array))

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

Michael A. Terrell

11/13/2012 6:07:00 PM

0


"Robert Westergrom,1900 Harvey rd.,Wilmington,D.E" wrote:
>
> On Nov 13, 9:53 am, "Michael A. Terrell" <mike.terr...@earthlink.net>
> wrote:
> > "Robert Westergrom,1900 Harvey rd.,Wilmington,D.E" wrote:
> >
> >
> >
> > > Are you saying Obama is dirt poor? He's just like you, right? He can
> > > feeeeelll yore pain. Don't worry. Within 3 years even those hated
> > > "rich" will be dumpster diving just like the rest of us.
> >
> > Except there won't be any dumpsters. The companies who own them will
> > be out of business.
>
> Out of business or have fled to another country to avoid Obama's
> stifling regulations and crushing taxes.


Cut their losses by selling the dumpsters as scrap steel before that
market collapses.