Capy-Bearer Documentation

Get or create a child

lib call

Capy

function get_or_create(value : dval, key : string, default : as dval) dval

Description

get_or_create(value, key, default) stores default when key is missing. It changes and returns value.

Parameters

value : target value

key : child key

default : value to store when the child is missing

Return Values

The target value.

Example

Capy

var config := dval({})
config = get_or_create(config, "host", "localhost")
print(config.host, "\n")