Please observe the result of these forEach, (1. and 2.):
1.
a!forEach( items: {1,2,3,4,5}, expression: if ( fv!item > 3, fv!item, {} )
)
results in
meanwhile
2.
a!forEach( items: {1,2,3,4,5}, expression: if ( fv!item > 3, fv!item, null )
Question: Why forEach 1. does not outcome five members in the list?, I expected this result
Discussion posts and replies are publicly visible
This is the expected result. In your first example, the fallback value is set as an empty set (i.e. an array of size zero), which by standard Appian convention is excluded from array result sets (at least when the entire array contains any non-empty value). This is very useful when it comes to creating a trimmed array where the only members meet a certain condition, since the negative case can typically just be set to an empty set such as is seen here.
In your second example, on the other hand, the fallback value is a single null, which is very different from an empty set - a null is considered to be (in terms of data type) a single value, just with a blank value, but that doesn't stop its data type from being singular. This is often used for example to insert nulls into arrays (or replace items in an array with null) wherein it's important for the array to maintain its original size/shape, but for individual items to be excluded due to whatever reasons are given in the logic.
Further I'd clarify that this doesn't really have anything in particular to do with a!forEach(), but rather, the behavior of empty sets and nulls in arrays overall (since at the end of the day, a!forEach() just generates an array). A simple example shows this pretty clearly: