I'm facing a problem in which I can't substitute a string in a cloned hash without affecting its original. I'd better explain using an example:
product_attributes = raw_attributes.clone
# do some stuff on product_attributes like removing hash elements using "select!"
puts product_attributes[:code]
# => 64020-001
puts raw_attributes[:code]
# => 64020-001
product_attributes[:code].gsub!(/[\/|\-][0-9\.]*$/, "")
puts product_attributes[:code]
# => 64020
puts raw_attributes[:code]
# => 64020
I use Ruby 1.9.3p327 on OSX.
Is this a known issue (or even a feature)? Or am I doing something wrong?