I was wondering why there seems to be no autocomplete (in R and RStudio) for R6 classes since they are environments and for 'regular' environments autocomplete is supported. I played around with the objects and noted that adding "environment" to the list of classes enables autocomplete again.
Queue <- R6Class("Queue",
public = list(
initialize = function(...) {
for (item in list(...)) {
self$add(item)
}
},
add = function(x) {
private$queue <- c(private$queue, list(x))
invisible(self)
},
remove = function() {
if (private$length() == 0) return(NULL)
# Can use private$queue for explicit access
head <- private$queue[[1]]
private$queue <- private$queue[-1]
head
}
),
private = list(
queue = list(),
length = function() base::length(private$queue)
)
)
tmp <- Queue$new()
class(tmp) <- c("Queue", "R6", "environment")
class(Queue) <- c("R6ClassGenerator", "environment")
I don't see if there is a particular reason to not adding it to the list of classes. I am aware of the argument class = FALSE but maybe the above would be a better default?
I was wondering why there seems to be no autocomplete (in R and RStudio) for R6 classes since they are environments and for 'regular' environments autocomplete is supported. I played around with the objects and noted that adding
"environment"
to the list of classes enables autocomplete again.I don't see if there is a particular reason to not adding it to the list of classes. I am aware of the argument
class = FALSE
but maybe the above would be a better default?