You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current printout does not show the default values for properties. The default could be shown in the constructor or next to the property. Displaying it next to the property might make more sense; otherwise, constructor printouts will get long, and we'd need to implement line breaks in the constructor printout.
library(S7)
Person<- new_class(
name="Person",
properties=list(
# non-dynamic, default missing (required constructor arg)first_name= new_property(class_character, default= quote(expr= )),
# non-dynamic, static default (optional constructor arg)middle_name= new_property(class_character, default=""),
# non-dynamic, default missing (required constructor arg) (same as first_name)last_name= new_property(class_missing|class_character),
# non-dynamic, but defaults to the value of another propertynick_name= new_property(class_character, default= quote(first_name)),
# non-dynamic, optional constructor argument, read-only after construction.birthdate= new_property(
class=class_Date,
default= quote(Sys.Date()),
setter=function(self, value) {
if (!is.null(self@birthdate))
stop("Can't set read-only property Person@birthdate")
self@birthdate<-valueself
}
),
# dynamic property, not a constructor argumentage= new_property(class=class_any, getter= \(self) {
Sys.Date() -self@birthdate
})
)
)
The text was updated successfully, but these errors were encountered:
t-kalinowski
changed the title
Update S7_classprint() method to show default property values
Update S7_classprint() method to show property default values
Sep 10, 2024
The current printout does not show the default values for properties. The default could be shown in the constructor or next to the property. Displaying it next to the property might make more sense; otherwise, constructor printouts will get long, and we'd need to implement line breaks in the constructor printout.
The text was updated successfully, but these errors were encountered: