Skip to content

is_empty

Checks whether a value is empty.

is_empty(x:string|list|record) -> bool

The is_empty function returns true if the input value is empty and false otherwise.

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.

from {
empty: "".is_empty(),
not_empty: "hello".is_empty(),
}
{
empty: true,
not_empty: false,
}
from {
empty: [].is_empty(),
not_empty: [1, 2, 3].is_empty(),
}
{
empty: true,
not_empty: false,
}
from {
empty: {}.is_empty(),
not_empty: {a: 1, b: 2}.is_empty(),
}
{
empty: true,
not_empty: false,
}
from {
result: null.is_empty(),
}
{
result: null,
}

length, has

Last updated: