Closed ericreg closed 7 years ago
It would be great if one could set a public method in the initializer. This can currently be forced by calling unlockBinding(sym, self) For example:
unlockBinding(sym, self)
class.Path <- R6Class("Path", public = list( initialize = function(path = NA) { t = seq(0, 1, length.out = nrow(path)) smooth.x = smooth.spline(t, path$X) smooth.y = smooth.spline(t, path$Y) smooth.z = smooth.spline(t, path$Z) unlockBinding("approximator", self) self$approximator <<- function(t, deriv = 0) { return(data.frame( x = predict(smooth.x, t, deriv = deriv)$y, y = predict(smooth.y, t, deriv = deriv)$y, z = predict(smooth.z, t, deriv = deriv)$y)); }; lockBinding("approximator", self) }, approximator = function() { } ), private = list( ))
I think this feature should be available. Given that R is a functional language, being able to set functions in the constructor.
Nevermind. This is possible by setting approximator = NULL. Ignore.
approximator = NULL
It would be great if one could set a public method in the initializer. This can currently be forced by calling
unlockBinding(sym, self)
For example:I think this feature should be available. Given that R is a functional language, being able to set functions in the constructor.