comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Copying a hash
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Copying a hash [message #81003] Mon, 06 August 2012 13:54 Go to previous message
Matt[3] is currently offline  Matt[3]
Messages: 23
Registered: April 2011
Junior Member
Hi All,

Does anyone know if there's a simple way that I can make a copy of a hash, which I can then edit independently of the original? For example, it seems that, like a pointer, changes that I make to the copy are also applied to the original:

IDL> original=hash('A', [1, 2])
IDL> copy=original
IDL> copy['A', 1]=10
IDL> print, copy
A: 1 10
IDL> print, original
A: 1 10

I can copy to a new hash key-by-key:

copy=hash()
foreach variable, original, key do copy[key]=original[key]

Which works fine, unless one of the elements in the hash is itself a hash, then I end up with the same problem one level down.

Is there something simple I'm missing here?

Cheers,

Matt
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: RESOLVE_ROUTINE not finding MEDIAN function?
Next Topic: mosaic

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:37:48 PDT 2025

Total time taken to generate the page: 0.00417 seconds