>>
>> What if the values in the hash are lambdas?
>
> Then yeah, the Marshal dump/load approach doesn't work. It *does* work
> for the presented example, though, whereas (given the implications of the
> requests in the original questions) your dup-or-clone approach does *not*
> work.

The #clone based method presented upthread (which wasn't mine, it was
7stud's) works perfectly for the data and requirements presented. It
doesn't work if, in addition to wanting to lose changes to the passed
hashes, one also wants to lose any changes resulting from manipulation
of the data in the hashes, but that wasn't requested.

That is, since you work on a local copy of each hash, mutating methods
called on the hash won't have any lasting effect, but mutating methods
called on keys or values extracted from the (local copy of the) hash
will affect the objects stored in the original hash. Avoiding this
kind of effect was not requested.

>
>
>>
>> The load/dump mechanism meets some other need, but doesn't meet the
>> original request for hashes with arbitrary data (and is an
>> extraordinarily convoluted mechanism for meeting the original request
>> even where it works.)
>
> 1. It meets the needs of the presented example data.

Sure, but its way overkill for it. You only need deep copies if you
have requirements that weren't stated (avoiding effects from mutating
methods called not on the hashes being passed but on the keys or
values of the hashes.)

>
> 2. Is there some less-convoluted approach that works for the more complex
> needs you presented?

I'm not sure what relevance this has. A deep copying solution that
handles arbitrary rather than merely serializable objects at the
fringes is going to be more complex than
Marshal.load(Marshal.dump(...)), but since either approach is more
convoluted than what is needed here, I don't see why that matters here
(and, since Marshal.load(Marshal.dump(...)) doesn't work for the cases
where you'd need the more sophisticated deep copying solution, I don't
see why the fact that the latter would be more complex would matter
there, either -- a simpler approach that doesn't work is still no
solution at all.)

>
> 3. How exactly does this make a dup-or-clone approach work such as what
> you presented work?

"this" doesn't make the dup-or-clone approach work, it is orthogonal
to the fact that the dup-or-clone approach, as presented (in #clone
form) by 7stud upthread _does_ work for the scenario presented.