/* * call-seq: * obj.dup -> an_object * * Produces a shallow copy of <i>obj</i>---the instance variables of * <i>obj</i> are copied, but not the objects they reference. * <code>dup</code> copies the tainted state of <i>obj</i>. See also * the discussion under <code>Object#clone</code>. In general, * <code>clone</code> and <code>dup</code> may have different semantics * in descendent classes. While <code>clone</code> is used to duplicate * an object, including its internal state, <code>dup</code> 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. */ VALUE rb_obj_dup(obj) VALUE obj; { VALUE dup; if (rb_special_const_p(obj)) { rb_raise(rb_eTypeError, "can't dup %s", rb_obj_classname(obj)); } dup = rb_obj_alloc(rb_obj_class(obj)); init_copy(dup, obj); return dup; }