Skip to contents

Given a Dictionary, retrieve objects with provided keys.

  • dictionary_sugar_get_safe() to retrieve a single object with key .key.

  • dictionary_sugar_mget_safe() to retrieve a list of objects with keys .keys.

  • If .key or .keys is missing, the dictionary itself is returned.

  • Dictionary getters without the _safe suffix are discouraged as this sometimes caused unintended partial argument matching.

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 <-.


dictionary_sugar_get_safe(.dict, .key, ...)

dictionary_sugar_mget_safe(.dict, .keys, ...)



The dictionary from which to retrieve the elements.


Key of the object to construct.


See description.


Keys of the objects to construct.


item = R6Class("Item", public = list(x = 0))
d = Dictionary$new()
d$add("key", item)
dictionary_sugar_get_safe(d, "key", x = 2)
#> <Item>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     x: 2