Let's say I have a class called Creature. I wish to provide a $clone() method for this class, so I set cloneable = TRUE, and it works as expected:
library(R6)
# define a class
Creature <- R6Class(
"Creature",
cloneable = TRUE
)
# cloning for class objects possible
Creature$new()$clone()
#> <Creature>
#> Public:
#> clone: function (deep = FALSE)
Now, let's say I create a subclass Human that inherits from Creature. For this class, I don't want to provide $clone() method. So I set cloneable = FALSE, but that doesn't work:
# create a subclass
Human <- R6Class(
"Human",
inherit = Creature,
cloneable = FALSE
)
# cloning still possible even when
# `cloneable` is set to `FALSE`
Human$new()$clone()
#> <Human>
#> Inherits from: <Creature>
#> Public:
#> clone: function (deep = FALSE)
Created on 2022-03-01 by the reprex package (v2.0.1.9000)
Let's say I have a class called
Creature
. I wish to provide a$clone()
method for this class, so I setcloneable = TRUE
, and it works as expected:Now, let's say I create a subclass
Human
that inherits fromCreature
. For this class, I don't want to provide$clone()
method. So I setcloneable = FALSE
, but that doesn't work:Created on 2022-03-01 by the reprex package (v2.0.1.9000)
Is it possible for
{R6}
to support this?