Skip to content

Instantly share code, notes, and snippets.

View mateusd24's full-sized avatar

Mateus Soares mateusd24

View GitHub Profile
@mateusd24
mateusd24 / 1. Success.rb
Last active February 13, 2020 21:08 — forked from Integralist/1. Success.rb
How to clone a Hash (in Ruby) and modify the cloned hash without affecting the original object
# This is the ONLY way I've found that works
# All other suggested solutions (see below examples) don't actually work
# And as an extra bonus: this deep copies as well!
def deep_copy(o)
Marshal.load(Marshal.dump(o))
end