Method: Object#dup

Defined in:
lib/source/ruby.rb

#dupObject

call-seq:

obj.dup -> object

Produces a shallow copy of obj – the instance variables of obj are copied, but not the objects they reference. 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.



294
295
296
297
298
299
# File 'lib/source/ruby.rb', line 294

def dup
  `var result=this.m$class.m$new()`
  `for(var x in this){if(x!='__id__'&&x.slice(0,2)!='i$'){result[x]=this[x];};}`
  `result.__id__=Red.id++`
  return `result`
end