From: Christopher Dicely Date: 2011-05-05T06:21:00+09:00 Subject: Re: Iterating over an Array of Hashes On Wed, May 4, 2011 at 1:50 PM, Chad Perrin wrote: > On Thu, May 05, 2011 at 04:17:53AM +0900, Christopher Dicely wrote: >> >> 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. > > Are you seriously claiming that the person's statements seemed to you to > indicate a desire for the data to change in the original data structure? No, I'm claiming that the original requester's statement didn't indicate a need to protect against changes resulting from calling mutating methods on the keys or values of the hashes, only protection from changes resulting from mutations on the hash. That could be because changes to things held in the hash were supposed to be propagated, or it (perhaps more likely) could be because the code in which it was to be used wasn't going to be calling mutating methods on the keys or values from the hash in any case. In the former case, a deep copy would be wrong, in the latter case it would merely be unnecessary.