Description Usage Arguments Value Examples
Assertion for controlling object, argument, and return types. Allows for the type checking of enums and enum members.
This function requires the typed package to operate. See
typed::?()
for more details.
1 |
... |
a value to check type assertions with |
any
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # If you leverage the {typed} package, you can make use
# of the `Enum()` assertion for type checking:
library(typed, quietly = TRUE, warn.conflicts = FALSE)
# Variable 'x' must correspond to an enum
Enum() ? x <- enum(a, b, c)
# Variable 'x' must correspond to a variable in an enum
Enum(enum(a, b, c)) ? x <- 2
# Argument 'x' must correspond to a variable in an enum
my_function <- ? function(x = ? Enum(enum(a, b, c))) {
print("success!")
}
# Function must return an enum
func_return <- Enum() ? function() {
return(
enum(a, b, c)
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.