reject(): drop the nulls from a list
Easy
Return the list with every null removed, keeping the rest in order.
The test goes in the first argument, and it has to be a function reference: the name with fn! in front of it, not a call.
Input
ri!values: List of Integer, possibly containing nulls
ri! Rule Inputs
ri!valuesList of Integer{
1,
null,
3
}Example 1: One null in the middle
Input: ri!values
{
1,
null,
3
}Expected output:
{
1,
3
}Example 2: Nothing but nulls
Input: ri!values
{
null,
null
}Expected output:
{}Example 3: No nulls at all
Input: ri!values
{
4,
5,
6
}Expected output:
{
4,
5,
6
}Example 4: Nulls at both ends
Input: ri!values
{
null,
7,
null
}Expected output:
{7}Example 5: Empty list
Input: ri!values
{}Expected output:
{}Appian Expression Tips
- • Use
ri!variableNamefor rule inputs - • Use
a!localVariables(local!x: …, body)for locals - • Use
a!forEach(items: …, expression: fv!item)to iterate - • Use
where()/reject(fn!isnull, list)to filter