Capy-Bearer Documentation

Get a named child

lib call

Capy

function get(value : any, key : string) any

Description

get(value, key) reads a named child without creating it. It returns none for a missing key or a scalar.

Parameters

value : source value

key : child key

Return Values

The child itself, or none.

Example

Capy

var user := {"email": "ada@example.test"}
print(user.get("email"), "\n")
print(get(user, "email"), "\n") // equivalent
print(user.email, "\n") // equivalent
print(user["email"], "\n") // equivalent

Output

ada@example.test
ada@example.test
ada@example.test
ada@example.test