default
function:
-
Can also be called as
defaults
-
Can also be called as
or_else
Get the first non empty value.
Examples:
- running:
(default (get . 1), (get . "key-1"), 22)
for input:{"key-1": 1, "key-2": false}
will give:1
Because the first get will return nothing because the input is an object and get should have a string argument, the second get will return 1, which is not a nothing, so it will be the returned value.
- running:
(default (get . 1), (get . "key-3"), 22)
for input:{"key-1": 1, "key-2": false}
will give:22
Because all theget
will return nothing, so 22 is the first non nothing argument.
- running:
(default (.get 1), (.get 2))
for input:100
will return nothing