Skip to content

Instantly share code, notes, and snippets.

@radavis
Created August 26, 2013 12:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radavis/6340885 to your computer and use it in GitHub Desktop.
Save radavis/6340885 to your computer and use it in GitHub Desktop.
Make a copy of an object in ruby
def deep_copy(obj)
# from: http://stackoverflow.com/a/8206537
# serializes the object, then unserializes it to make a duplicate
return Marshal.load(Marshal.dump(obj))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment