RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

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.


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

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in