The differences between dup and clone in Ruby
I just wrote a quick explanation with examples of the differences between copying and cloning a Ruby object. I’ve also added a quick explanation of shallow object copying.
I just wrote a quick explanation with examples of the differences between copying and cloning a Ruby object. I’ve also added a quick explanation of shallow object copying.
Comments
AWESOME. I had no idea clone copied singleton class and dup didn’t. That matters. If you submitted a doc patch to MRI to actually document this in Object#dup and Object#clone, that’d be super kind!
Post a comment