( ), @<- setter setFirstSlot, , . , .
, , , . , @<- x ( numeric), .
setClass('foo', representation(x = 'numeric', y = 'numeric'))
f <- new('foo')
f@x <- 1
f@y <- 2
f@x <- "a"
, . @<-:
f@x <- c(1, 2, 3, 4)
f@x
setter, . , , .
, . setValidity , , @<- validObject, f@x <- c(1, 2, 3, 4) , setValidity
valid.foo <- function(object)
{
if (length(object@x) > 1)
stop("slot ", sQuote("x"), " must be of length 1")
}
setValidity("foo", valid.foo)
f@x <- c(1, 4, 6)
f@x
validObject(f)
. set.x.inplace .
setGeneric("set.x.inplace", function(object, val){ standardGeneric("set.x.inplace") })
setMethod("set.x.inplace", "foo", function(object, val)
{
if (length(val) == 1) {
eval(eval(substitute(expression(object@x <<- val))))
} else
stop("slot ", sQuote("x"), " must be of length 1")
})
set.x.inplace(f, 6)
f
set.x.inplace(f, c(1,2,3))
, .