| prop_names | R Documentation |
prop_names(x) returns the names of the properties
prop_exists(x, "prop") returns TRUE and if only x has property
prop.
prop_info() returns a data frame describing the properties of an S7
object or class, with one row per property.
prop_names(object)
prop_exists(object, name)
prop_info(object)
object |
Either an S7 object (an instance) or an S7 class. |
name |
A string giving the property of interest. |
prop_names() returns a character vector
prop_exists() returns a single TRUE or FALSE.
prop_info() returns a data frame with one row per property and the
following columns:
name: a character vector of property names.
default: a list column of property defaults.
class: a character description of the class.
getter, setter, validator: logical vectors indicating whether
the property has a getter, setter, or validator.
Horse := new_class(properties = list(
name = class_character,
colour = class_character,
height = new_property(class_numeric, default = 15),
age = new_property(
class_numeric,
validator = function(value) if (value < 0) "must be positive"
),
now = new_property(getter = function(self) Sys.time())
))
prop_names(Horse)
prop_exists(Horse, "col")
prop_exists(Horse, "colour")
prop_info(Horse)
# All functions also work with objects, not just classes
lex <- Horse(colour = "bay", height = 15, name = "Lex", age = 3)
prop_names(lex)
prop_exists(lex, "age")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.