Closed cdeterman closed 6 years ago
Is there a way to have an R6 class return the name of it's class. For example:
myClass <- R6Class( "myClass", public = list( getClass = function(){ #print(self$classname) } ) )
I would expect it to return "myClass"
"myClass"
I could simply add another field internally that simply populates self$classname as the class but I didn't know if there was an internal method already implemented like you would see with a python class like this self.__class__.__name__.
self$classname
self.__class__.__name__
You could do something like this:
myClass <- R6Class( "myClass", public = list( getClass = function(){ class(self)[1] } ) ) m <- myClass$new() m$getClass() #> [1] "myClass"
Is there a way to have an R6 class return the name of it's class. For example:
I would expect it to return
"myClass"
I could simply add another field internally that simply populates
self$classname
as the class but I didn't know if there was an internal method already implemented like you would see with a python class like thisself.__class__.__name__
.