Sha256: a1d4aeb81a6556eaa53df9969699314b4934024dd616e71f74a614c2abaaefae
Contents?: true
Size: 362 Bytes
Versions: 2
Compression:
Stored size: 362 Bytes
Contents
# encoding: utf-8 class Object # Object#dup is shallow and therefore useless: # # a = { name: { first: 'Georgi' } } # dupl = a.dup # # #this also changes a when it shouldn't # dupl[:name][:first] = 'Dazen' # # a # => :name=>{:first=>"Dazen"}} # # deep_dup fixes this behavior def deep_dup Marshal.load(Marshal.dump(self)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
inactive_support-1.3.0 | lib/inactive_support/object/deep_dup.rb |
inactive_support-1.2.0 | lib/inactive_support/object/deep_dup.rb |