From: ruby gem Date: 2012-05-06T22:52:09+09:00 Subject: Re: proper way to create truly new dup/cloned object? I think it is possible one of my gems is overriding the default behavior of dup, fast_xor: puts @l puts cloned_l cipher = OpenSSL::Cipher::Cipher.new 'AES-256-CTR' cipher.encrypt cipher.key = cloned_l.xor!(subkey) ciphertext = cipher.update(@r) ciphertext << cipher.final @r = ciphertext puts @l puts cloned_l output: 8bll��h�43��u3;S�/�=� @QM�W 8bll��h�43��u3;S�/�=� @QM�W 톭qWOʁ/@�FI`�#����//��͟}��l 톭qWOʁ/@�FI`�#����//��͟}��l is it possible for gem to over ride dup in this way? And if so how would you suggest going about this? my @l value changes over time , and fast_xor only does in place operations but in some instances I need to get l.xor! without the in place. I thought making a dup of it when I need its current value, but don't want to change the original string, would work. But it seems like it doesn't work because if it did it should output this 8bll��h�43��u3;S�/�=� @QM�W 8bll��h�43��u3;S�/�=� @QM�W 8bll��h�43��u3;S�/�=� @QM�W 톭qWOʁ/@�FI`�#����//��͟}��l can you think of an elegant way to do this? I don't want to have to keep adding and taking a bunch of things out of hashes but I am starting to think that is the only option. -- Posted via http://www.ruby-forum.com/.