prop {S7}R Documentation

Get/set a property

Description

Usage

prop(object, name)

prop(object, name, check = TRUE) <- value

object@name

Arguments

object

An object from a S7 class

name

The name of the parameter as a character. Partial matching is not performed.

check

If TRUE, check that value is of the correct type and run validate() on the object before returning.

value

A new value for the property. The object is automatically checked for validity after the replacement is done.

Value

prop() and @ return the value of the property. ⁠prop<-()⁠ and ⁠@<-⁠ are called for their side-effects and return the modified object, invisibly.

Examples

horse <- new_class("horse", properties = list(
  name = class_character,
  colour = class_character,
  height = class_numeric
))
lexington <- horse(colour = "bay", height = 15, name = "Lex")
lexington@colour
prop(lexington, "colour")

lexington@height <- 14
prop(lexington, "height") <- 15

[Package S7 version 0.1.1 Index]