get_or_else: get_or_else

Description Usage Arguments

View source: R/list_manipulation.R

Description

Given a list .x, this function looks to see if the field .field is defined within that list. If it is defined, the value for that entry is returned. If .field is not defined, then the function either returns the value .default_val or the value .default_fn(.field). The latter is lazily evaluated, ie, it's only computed if .field is not in .x.

Usage

1
get_or_else(.x, .field, .default_val, .default_fn)

Arguments

.x

A list

.field

A string. This may or may not be one of the names in the list .x; if it is the associated value is returned. If not either .default_val or .default_fn(.field) is returned.

.default_val

A value that is to be returned if .field is not in .x. Only one of .default_val and .default_fn may be defined.

.default_fn

A single argument function that is evaluated if .field is not in .x. The value .field is passed into this function as an argument. Only one of .default_val and .default_fn may be defined.


russHyde/miiq documentation built on Dec. 25, 2019, 10:56 a.m.