objectSignals (version 0.10.2)

fieldWithPrototype: Fields with prototypes

Description

A convenience for declaring a default value for a field, in the vein of prototype for S4 classes, except the default value is quoted and evaluated lazily.

Usage

fieldWithPrototype(name, class, value)

Arguments

name

The name of the field

class

The class of the field

value

Default value that when evaluated initializes the field

Value

A list suitable for use with setRefClass

Examples

Run this code
# NOT RUN {
Brush.gen <- setRefClass("Brush",
fields = fieldWithPrototype("color", "character", "red"))
brush <- Brush.gen$new()
brush$color
brush$color <- "blue"
brush$color
# }

Run the code above in your browser using DataLab