Define a property backed by one or more enum classes
Arguments
- ...
Enum classes. One or more classes from
new_enum().- default
Any. Passed to
S7::new_property().
Examples
library(S7)
GridShape <- new_enum("GridShape", c("Square", "Hexagon"))
#> Overwriting method convert(<character>, <GridShape>)
Direction <- new_enum("Direction", c("North", "South"))
Board := new_class(
properties = list(orientation = property_enum(GridShape, Direction))
)
Board(GridShape("Square"))
#> <Board>
#> @ orientation: <GridShape>
#> .. @ value : chr "Square"
#> .. @ variants: chr [1:2] "Square" "Hexagon"
#> .. @ allow_na: logi TRUE