Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Proposing feature requests to the R Core Team
- setRefClass(
- "A",
- fields=list(a="numeric", b="character"),
- methods=list(
- reset=function(fields=NULL, ...){
- temp <- new("A")
- if(is.null(fields)){
- fields <- names(getRefClass("A")$fields())
- }
- sapply(fields, function(x){
- .self$field(name=x, value=temp$field(x))
- })
- return(TRUE)
- }
- )
- )
- x <- new("A", a=1:10, b=letters[1:10])
- x$a
- x$b
- x$reset(fields="a")
- x$a
- x$b
- x$reset()
- x$a
- x$b
Add Comment
Please, Sign In to add comment