ruby-deepclone
ruby-deepclone copied to clipboard
Cloning Struct
I am trying to deep clone a Struct element, but DeepClone does not seem to work as expected.
2.3.1 :001 > require "deep_clone"
=> true
2.3.1 :002 > AStruct = Struct.new(:test)
=> AStruct
2.3.1 :003 > a = AStruct.new("ciao")
=> #<struct AStruct test="ciao">
2.3.1 :004 > b = a.clone
=> #<struct AStruct test="ciao">
2.3.1 :005 > c = DeepClone.clone(a)
=> #<struct AStruct test="ciao">
2.3.1 :006 > a.test = "hello"
=> "hello"
2.3.1 :007 > a
=> #<struct AStruct test="hello">
2.3.1 :008 > b
=> #<struct AStruct test="ciao">
2.3.1 :009 > c
=> #<struct AStruct test="hello">