Usage
## S3 method for class 'Class}(this, ...)':
isBeingCreatedundefined
- ...
{Not used.}
Returns TRUE
if a static instance exists, otherwise FALSE
.
setConstructorS3("Car", function(brand=NULL, nbrOfWheels=0) {
if(!isBeingCreated(Car)) {
if (is.null(brand))
throw("A car must have a brand")
if (nbrOfWheels <= 0)="" throw("a="" car="" must="" have="" one="" or="" more="" wheels:="" ",="" nbrofwheels)="" }="" extend(object(),="" "car",="" .brand="brand," .nbrofwheels="nbrOfWheels" )="" })="" setmethods3("as.character",="" function(this,="" ...)="" {="" cat(class(this)[1],="" ":",="" this$.brand,="" "="" with="" this$.nbrofwheels,="" wheels.",="" sep="" );="" print(car("volvo",="" 4))="" print(car("bmw",="" print(car("tyrrell="" p34",="" 6))="" print(car("t-rex",="" 3))<="" examples="">
[object Object]
For more information see Class
.
internal
methods
programming=>