Skip to contents

TRUE when x is a value of an R8 enum whose variant is variant, a variant that the enum declares. A rule tests a field's variant with the rule dialect's is_variant(kernel, "Rbf") (rule()).

Usage

r8is_variant(x, variant)

Arguments

x

An R8 enum value.

variant

Character: The variant's name, one value.

Value

Logical: One value.

Details

The name is checked against the enum's declaration, so a misspelled name is an error; for a value whose type is not registered in the session, the names are compared only.

See also

r8variant(), the variant's name.

Examples

op <- options(r8.namespace = "demo")
Shape <- new_enum("Shape", variants = list(Circle = variant(), Square = variant()))
r8is_variant(Shape@Circle, "Circle")
#> [1] TRUE
try(r8is_variant(Shape@Circle, "Circel"))
#> Error : `Circel` is not a variant of `demo::Shape`; the nearest variant is `Circle`. Variants: Circle, Square.
options(op)