props(x) returns all properties.
props(x) <- list(name1 = val1, name2 = val2) modifies an existing object
by setting multiple properties simultaneously.
set_props(x, name1 = val1, name2 = val2) creates a copy of an existing
object with new values for the specified properties.
props(object, names = prop_names(object))
props(object) <- value
set_props(object, ...)A named list of property values.
Horse <- new_class("Horse", properties = list(
name = class_character,
colour = class_character,
height = class_numeric
))
lexington <- Horse(colour = "bay", height = 15, name = "Lex")
props(lexington)
#> $name
#> [1] "Lex"
#>
#> $colour
#> [1] "bay"
#>
#> $height
#> [1] 15
#>
props(lexington) <- list(height = 14, name = "Lexington")
lexington
#> <Horse>
#> @ name : chr "Lexington"
#> @ colour: chr "bay"
#> @ height: num 14