Item getter with default
[data/dictionary/Item getter with default]

Retrieves an item's value by its key from a dictionary. If the item is not found, the specified default value is sent. Example A:
{ "first": 1, "third": 3, "fifth": 5 } @0 received via
dict
"first"@0 received via
key
value
sends 1@0
Example B:
2 assigned to
default
{ "first": 1, "third": 3, "fifth": 5 } @0 received via
dict
"second"@0 received via
key
value
sends 2@0
More: https://github.com/Cranq-io/cranq-tutorials/tree/main/reference/3_querying_data/3_1_getters
Keywords: variable, container, buffer, data, default, fallback
Input ports
dict:
{string: any}
Receives the dictionary to get the value from. Example: { "first": 1, "third": 3, "fifth": 5 }
key:
string
Receives the key corresponding to the value to get. Example: "third"
default:
{string: any}[string]
Receives the default value to be sent when the requested key is absent. Must be parameter. Example: 2
Output ports
value:
{string: any}[string]
Sends the value corresponding to the specified key, or, when not found, the specified default value. Example: 1
Last updated