NamedList: NamedList

NamedListR Documentation

NamedList

Description

A class for lists with key-value pairs - aka in R: named lists

Super classes

staypuft::FieldABC -> staypuft::Field -> NamedList

Methods

Public methods

Inherited methods

Method new()

Usage
NamedList$new(keys, values, ...)

Method serialize_()

Usage
NamedList$serialize_(value, attr = NULL, obj = NULL)

Method deserialize_()

Usage
NamedList$deserialize_(value, attr = NULL, data = NULL)

Method clone()

The objects of this class are cloneable with this method.

Usage
NamedList$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

x <- Schema$new("foo",
  title = fields$character(),
  age = fields$integer(strict = TRUE),
  name = fields$named_list(keys=fields$character(), values=fields$number())
)
x
# good
x$load(list(
  title = "barry", 
  age = 3L, 
  name = list(foo = 3.4, iff = 5)))
# bad
if (interactive()) {
x$load(list(
  title = "barry", 
  age = 3L, 
  name = list(foo = 3.4, iff = "a")))

x$load(list(
  title = "barry", 
  age = 3L, 
  name = list("bar", "else")))
}

ropensci/staypuft documentation built on Sept. 9, 2022, 4:35 p.m.