From ggrothendieck at gmail.com  Thu Feb 28 21:44:03 2013
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Thu, 28 Feb 2013 15:44:03 -0500
Subject: [Rd] Return value of S4 validity function
Message-ID: <CAP01uRkz=jagOQf_7V3zKw5cBvFKWDUgJ+jiNAsv1i9eMVgxMg@mail.gmail.com>

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



[Rd] Return value of S4 validity function
Gabor Grothendieck