Guest User

Untitled

a guest
Feb 20th, 2018
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. From 52d5bcc85b0cb1d8a86b471418818bcca27071a6 Mon Sep 17 00:00:00 2001
  2. From: Jack Dempsey <jack.dempsey@gmail.com>
  3. Date: Tue, 16 Sep 2008 18:25:23 -0400
  4. Subject: [PATCH] Add in deep_clone method
  5.  
  6. ---
  7. lib/extlib/object.rb | 7 +++++++
  8. 1 files changed, 7 insertions(+), 0 deletions(-)
  9.  
  10. diff --git a/lib/extlib/object.rb b/lib/extlib/object.rb
  11. index 2414fe4..2dd985f 100644
  12. --- a/lib/extlib/object.rb
  13. +++ b/lib/extlib/object.rb
  14. @@ -136,6 +136,13 @@ class Object
  15. self.dup
  16. end
  17.  
  18. + # Performs a deep clone of an object
  19. + #
  20. + # @return <Object>
  21. + def deep_clone
  22. + Marshal::load(Marshal.dump(self))
  23. + end
  24. +
  25. # @param arrayish<#include?> Container to check, to see if it includes the object.
  26. # @param *more<Array>:: additional args, will be flattened into arrayish
  27. #
  28. --
  29. 1.5.5.1
Add Comment
Please, Sign In to add comment