method

dup

v1_9_1_378 - Show latest stable - Class: Object
dup()
public

Produces a shallow copy of obj—the instance variables of obj are copied, but not the objects they reference. dup copies the tainted state of obj. See also the discussion under Object#clone. In general, clone and dup may have different semantics in descendent classes. While clone is used to duplicate an object, including its internal state, dup typically uses the class of the descendent object to create the new instance.

This method may have class-specific behavior. If so, that behavior will be documented under the #initialize_copy method of the class.

1Note

Dup vs Clone difference

aberezovskiy · Jul 15, 20111 thank

As for me main difference between .dup and .clone , that first one doesn't not freeze result object if initial object was frozen.