On Thu, Feb 28, 2013 at 3:44 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:> 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.
>
Pressed return too quickly. This should have continued on to give this example:
new("A")
with and without the ## line both of which work since it appears that
NULL can be used in place of TRUE.
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com