GenericClass {poems} | R Documentation |
R6 class with generic reusable functionality
Description
R6
class with generic (abstract) new cloning functionality.
Public fields
object_generator
Class object generator used to create new clones, particularly for user inheritance.
attached
A list of dynamically attached attributes (name-value pairs).
Methods
Public methods
Method new()
Initialization method saves an object generator for new cloning.
Usage
GenericClass$new(object_generator = NULL, ...)
Arguments
object_generator
Class object generator used to create new clones, particularly for user inheritance.
...
Parameters passed individually (ignored).
Method new_clone()
Creates a new (re-initialized) object of the current (inherited) object class with optionally passed parameters.
Usage
GenericClass$new_clone(...)
Arguments
...
Parameters passed via the inherited class constructor (defined in initialize and run via new).
Returns
New object of the current (inherited) class.
Method clone()
The objects of this class are cloneable with this method.
Usage
GenericClass$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
object1 <- GenericClass$new()
class(object1)
# Referencing
object_ref <- object1
object_ref$attached$a <- 1
object1$attached
# Cloning
object2 <- object1$clone()
object2$attached$b <- 2
object1$attached
object2$attached
# New cloning
object3 <- object1$new_clone()
object3$attached$c <- 3
object1$attached
object3$attached
[Package poems version 1.3.1 Index]