Reputation: 1
library(R6)
pre <- R6Class("pre",
public = list(
dbl = NULL,
initialize = function(){},
functionA = function(){},
functionB = function() {}
) )
Here is the code I want:
FunctionA ()
{
FunctionB ()
}
But there is an error here.
Error: could not find function "functionB"
Please let me know how to fix it.
Upvotes: 0
Views: 97
Reputation: 7635
FunctionA = function()
{
self$FunctionB ()
}
should do the trick. It is necessary to put self
before the name of the memberfunction unless you make your class non-portable. Here is a complete example
library(R6)
pre <- R6Class(public = list(
functionA = function(){self$functionB()},
functionB = function(){"output from B"}
))
obj <- pre$new()
obj$functionA()
# "output from B"
obj$functionB()
# "output from B"
Upvotes: 0