not_null
Find first argument that is not null
Definition
any not_null(any *$argument [, any $...])
Returns the first argument that does not resolve to null. Accepts one or more arguments, and will evaluate them in order until a non-null argument is encountered. If all arguments' values resolve to null
, then a value of null is returned.
Parameters
any *$argument
One or more arguments of any type, separated by comma.
Returns
any
The first argument provided that does not resolve to null
.
Examples
{
"null1": null,
"null2": null,
"empty_array": [],
"text": "alpha"
}
{
a: not_null(nonexistent, null1, null2, empty_array, text),
b: not_null(null1, null2, `null`, text, empty_array),
c: not_null(null1, null2)
}
{
"a": [],
"b": "alpha",
"c": null
}
Updated about 1 year ago