Created
August 26, 2013 12:23
-
-
Save radavis/6340885 to your computer and use it in GitHub Desktop.
Make a copy of an object in ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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