Checks whether a value is empty.
is_empty(x:string|list|record) -> bool
Description
Section titled “Description”The is_empty
function returns true
if the input value is empty and false
otherwise.
x: string|list|record
Section titled “x: string|list|record”The value to check for emptiness.
The function works on three types:
- Strings: Returns
true
for empty strings (""
) - Lists: Returns
true
for empty lists ([]
) - Records: Returns
true
for empty records ({}
)
For null
values, the function returns null
. For unsupported types, the
function emits a warning and returns null
.
Examples
Section titled “Examples”Check if a string is empty
Section titled “Check if a string is empty”from { empty: "".is_empty(), not_empty: "hello".is_empty(),}
{ empty: true, not_empty: false,}
Check if a list is empty
Section titled “Check if a list is empty”from { empty: [].is_empty(), not_empty: [1, 2, 3].is_empty(),}
{ empty: true, not_empty: false,}
Check if a record is empty
Section titled “Check if a record is empty”from { empty: {}.is_empty(), not_empty: {a: 1, b: 2}.is_empty(),}
{ empty: true, not_empty: false,}
Null handling
Section titled “Null handling”from { result: null.is_empty(),}
{ result: null,}