[Rd] Return value of S4 validity function
Gabor Grothendieck
ggrothendieck at gmail.com
Thu Feb 28 21:44:03 CET 2013
This issues a message about a needing to be non-negative as expected:
setClass("A",
representation = list(a = "numeric"),
prototype = list(a = 0),
validity = function(object) {
out <- if (object at a < 0) "a must be non-negative"
if (is.null(out)) TRUE else out ##
})
new("A", a = -1)
but it also works if the ## line is omitted so it appears that one can
use NULL in place of TRUE. I wonder if the use of NULL as an
alternative to TRUE could be officially supported as it would allow
one to write validity methods in a more concise manner. It appears
that this would only require a change to the documentation.
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-devel
mailing list