clone

0th

Percentile

Object cloner

Generic function to clone objects

Keywords
programming
Usage
clone(x, ...)
Arguments
x
An object to clone
...
Further arguments, ignored
Value

  • A clone of the object

Warning

The implementation of clone for java object references uses the clone method of the Object class. The reading of its description in the java help page is strongly recommended.

Aliases
  • clone
  • clone,jobjRef-method
  • clone,jarrayRef-method
  • clone,jrectRef-method
Examples
.jinit()
# we can run this example only if AWT is enabled
if (!nzchar(Sys.getenv("NOAWT"))) {
  p1 <- .jnew("java/awt/Point" )
  p2 <- clone( p1 )
  p2$move( 10L, 10L )
  p1$getX() 

  # check that p1 and p2 are not references to the same java object
  stopifnot( p1$getX() == 0 )
  stopifnot( p2$getX() == 10 )
}
Documentation reproduced from package rJava, version 0.9-1, License: GPL-2

Community examples

Looks like there are no examples yet.