The constructors new_numeric_enum() and new_generic_enum() are the basis for the enum() command. These can be used instead of enum() if speed is pivotal.

  • new_numeric_enum() creates and validates a numeric enum from a named list of numeric arguments

  • new_generic_enum() creates and validates a generic enum from a named list of arguments

These constructors do not have the helpers associated with the enum() command, such as easy NSE or enum class detection.

In general, it is recommended to use the enum() method, as it is less verbose, easier to read and write, and more readily picks up on user errors.

new_numeric_enum(.enum_data)

new_generic_enum(.enum_data)

Arguments

.enum_data

named list of arguments

Value

An enumeration (enum), a list of unique name/value pairs.

See also

Examples

new_numeric_enum(list(x = 5, y = 2))
#> # A numeric enum: 2 members #> num x : 5 #> num y : 2
new_generic_enum(list(x = mtcars, y = "string"))
#> # A generic enum: 2 members #> df x : <32 × 11> #> chr y : string