Message-ID: <CABdHhvFOcTbX0YnQ8Uiz6C_QdWX_hu9kuA7gD8XgDLg+voEzrQ@mail.gmail.com>
Date: 2013-03-28T18:40:03Z
From: Hadley Wickham
Subject: Ref classes initFields has incorrect environment?
As suggested by the following code:
A <- setRefClass("A", fields = list(x = "logical"),
methods = list(initialize = function(...) {
x <<- FALSE
initFields(...)
}))
A$new()
# Works as expected
quote <- as.character
A$new()
# Error in function (value) :
# invalid replacement for field ?x?, should be from class ?logical?
or a subclass (was class ?character?)
I get the same error in:
* R version 2.15.2 (2012-10-26)
* R version 2.15.3 (2013-03-01)
* R Under development (unstable) (2013-03-28 r62432)
Hadley
--
Chief Scientist, RStudio
http://had.co.nz/