when I study clone vs dup, I tried copy a object like below :
a = {'key1' => 1, 'key2' => {'key3' => 3, 'key4' => 4}}.freeze
b = a.clone
c = a.dup
a['key1'] = 32
# => RuntimeError: can't modify frozen Hash
b['key1'] = 32
# => RuntimeError: can't modify frozen Hash
c['key1'] = 32
# => 32
upper case result that, a and b value are share the memory but, when I check variable object_id, it returns different result :
a.object_id ## original
=> 70219554622880
b.object_id ## clone
=> 70219554589820
but in hash key object_id is same.
a['key1'].object_id ## original
=> 3
b['key1'].object_id ## clone
=> 3
c['key1'].object_id ## dup
=> 65
I don't understand a and b variable dosen't match object_id, but in hash key object_id is same.
Can you give me your thoughts, answers, or input? thanks.