ha = {foo: "hoge"} ha2 = ha.dup ha2[:foo].reverse! #=> "egoh" ha #=> {:foo=>"egoh"} class AnzenHash < Hash def [](key) immutable?(value = super) ? value : value.dup end undef []= private def immutable?(value) value.frozen? || [Fixnum, Symbol, TrueClass, FalseClass, NilClass].any?{|k| value.is_a? k } end end ha = {foo: "hoge"} ha2 = AnzenHash[ha] ha2[:foo] #=> "hoge" ha2[:foo].reverse! #=> "egoh" h