Learn R Programming

mlr3misc (version 0.1.3)

dictionary_sugar: A Quick Way to Initialize Objects from Dictionaries

Description

Given a Dictionary, retrieves the object with key key. Arguments in ... must be named and are consumed in the following order:

  1. All arguments whose names match the name of an argument of the constructor are passed to the $get() method of the Dictionary for construction.

  2. All arguments whose names match the name of a parameter of the paradox::ParamSet of the constructed object are set as parameters. If there is no paradox::ParamSet in obj$param_set, this step is skipped.

  3. All remaining arguments are assumed to be regular fields of the constructed R6 instance, and are assigned via <-.

Usage

dictionary_sugar(dict, .key, ...)

Arguments

dict
.key

:: character(1) Key of the object to construct.

...

:: any See description.

Value

R6::R6Class()

Examples

Run this code
# NOT RUN {
library(R6)
item = R6Class("Item", public = list(x = 0))
d = Dictionary$new()
d$add("key", item)
dictionary_sugar(d, "key", x = 2)
# }

Run the code above in your browser using DataLab