We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I create a class with a read-only active binding, then try to set the value, the error message is a bit obscure. To reproduce:
library(R6) thing_factory <- R6Class( "Thing", private = list( ..a_field = "a value" ), active = list( a_field = function() { private$..a_field } ) ) a_thing <- thing_factory$new() a_thing$a_field <- "a new value" ## Error in (function () : unused argument (quote("a new value"))
It would be clearer for the user if the message explained that a_field was read-only.
a_field
The text was updated successfully, but these errors were encountered:
Unfortunately, this is what R does with active bindings:
e <- new.env() makeActiveBinding("x", function() { 1 }, e) e$x <- 2 # Error in (function () : unused argument (quote(2))
I wish there were a straightforward way to make nicer error messages, but I don't think it's possible without changing code in R itself.
Sorry, something went wrong.
What about:
e <- new.env() makeActiveBinding("x", function(value) { if (!missing(value)) { stop("x is read only", call. = FALSE) } 1 }, e) e$x e$x <- 2
No branches or pull requests
If I create a class with a read-only active binding, then try to set the value, the error message is a bit obscure. To reproduce:
It would be clearer for the user if the message explained that
a_field
was read-only.The text was updated successfully, but these errors were encountered: