oneoffVariable(default = NULL)
NULL
.a function with one argument (value
) that provides
get/set access to a global variable. If called with a
value, it assigns this value to the global variable. If
called with no argument, it returns the current value of
the global variable and reset it to its default value --
as defined at its creation.
Defines a function that allow to get/assign a global variable whose value is ensured to be reset after each access.
x <- oneoffVariable(0)# returns default valuex()[1] 0# assign a valuex(3)# get the valuex()[1] 3# second call returns default value againx()[1] 0