Reputation: 2399
Reproducible example:
Parent <- R6::R6Class(
"Parent",
lock_objects = FALSE,
public = list(
initialize = function() {
# I wan't to create many methods dynamically in the loop.
self[["foo"]] <- function() {
print('foo')
}
}
)
)
Child <- R6::R6Class(
"Child",
inherit = Parent,
lock_objects = FALSE,
public = list(
foo = function() {
super$foo()
}
)
)
child <- Child$new()
Error:
Error in self$foo <- function() { :
cannot change value of locked binding for 'foo'
Why I'm getting this error when in both Parent and Child lock_objects = FALSE
?
Upvotes: 2
Views: 45