def deep_dup(obj)
      obj_class = obj.class
      if obj_class == Hash
        obj.reduce({}) do |result, (k, v)|
          result[k] = deep_dup(v)
          result
        end
      elsif obj_class == Array
        obj.map { |v| deep_dup(v) }
      elsif obj_class == String
        obj.dup
      else
        obj
      end
    end
def deep_dup(obj)
      obj_class = obj.class
      if obj_class == Hash
        obj.reduce({}) do |result, (k, v)|
          result[k] = deep_dup(v)
          result
        end
      elsif obj_class == Array
        obj.map { |v| deep_dup(v) }
      elsif obj_class == String
        obj.dup
      else
        obj
      end
    end
Create a deep copy of an object.

 Only objects which are of type String, Array, or Hash are deep copied.
 Any other object just has its referenced copied.

 @param obj [Object] Object to deep copy.

 @return [Object] Deep copied value.