Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/magnum-pi/core_ext/deep_clone.rb

Instance Method Summary collapse

Instance Method Details

#deep_clone(cache = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/magnum-pi/core_ext/deep_clone.rb', line 37

def deep_clone(cache = {})
  return cache[self] if cache.key?(self)

  copy = super

  each_with_index do |value, index|
    copy[index] = value.deep_clone(cache)
  end

  copy
end