Learn R Programming

brand.yml (version 0.1.0)

brand_pluck: Extract a nested element from a brand object

Description

Safely extracts a nested element from a brand object using the provided key path. Returns NULL if the element doesn't exist.

Usage

brand_pluck(brand, ...)

Value

The value of the nested element if it exists, NULL otherwise.

Arguments

brand

A brand object created by read_brand_yml() or as_brand_yml().

...

One or more character strings or symbols representing the path to the nested element.

See Also

Other brand.yml helpers: brand_color_pluck(), brand_has(), with_brand_yml_path()

Examples

Run this code
brand <- as_brand_yml(list(
  meta = list(name = "Example Brand"),
  color = list(primary = "#FF5733")
))

# Extract the primary color
brand_pluck(brand, "color", "primary") # "#FF5733"

# Try to extract a non-existent element
brand_pluck(brand, "color", "secondary") # NULL

Run the code above in your browser using DataLab