[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Recursive dup

Phillip Gawlowski

5/5/2008 2:07:00 PM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Iñaki Baz Castillo wrote:

| I know that I should personalize "dup" method for class A, but is not
| any other way? Does exist any automatic way of doing it?
| I expect some method "dup_recursive" that looks for objects into
| attributes recursively and clones them instead of reference.

If your storage of objects can be enumerated, you could use .each,
duplicate the objects you store, and re-store them.

That doesn't seem terribly efficient, though, so proceed with caution
(but it may get you started in the right direction :).

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.bl...

Make sure comments and code agree.
~ - The Elements of Programming Style (Kernighan & Plaugher)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail....

iEYEARECAAYFAkgfFI4ACgkQbtAgaoJTgL9g/wCghdYgjUs5o0cNsmxItj8yHOT9
pKEAnAxds5jvXuulwEphsjRtCx1UFwCP
=TiIJ
-----END PGP SIGNATURE-----