Re: [R] Enumeration in R

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Wed 07 Jul 2004 - 10:44:25 EST

Paul Roebuck <roebuck@odin.mdacc.tmc.edu> writes:

> I want the equivalent of this 'C' declaration.
> enum StoplightColor {
> green = 3,
> yellow = 5,
> red = 7
> };
>
> This mostly works except the validity checking doesn't
> seem to occur automatically. What didn't I do to enable
> it?

I think you *dis*abled it by specifying an initializer which doesn't check the validity:

> initialize.stoplightColor <- function(.Object, value) {
> .Object@value <- as.integer(value)
> .Object
> }

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jul 07 10:49:54 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:46:10 EST