I been trying to use the correct way for years now, it seems there is not enough documentation online. I know you can use fn!isnull but is there other functions similar to it? All I want to do is to compare to a simple item. If array contains 3, then remove it. Is there a way to identify a single item like fv!item?
a!localVariables( local!array:{1,2,3,4}, reject(fv!item=3, local!array))
wish it will return {1,2,4}
Discussion posts and replies are publicly visible
I'm unclear what exactly you're trying to do but it seems like you're trying to use an a!forEach() loop, but for whatever reason you've left out the a!forEach() call that would be needed. "fv!item" is a property that's only accessible within an a!forEach() loop, which is why you're getting the error message in your screenshot.
I've found that reject() is no longer needed in basically any use case, because now you can just have a!forEach() check for your exclusion condition and return an empty set on that position in the array. As long as there are any other non-empty results, empty sets will be ignored in the final result (and if you need to handle the case of all empties, then wrap the entire a!forEach() statement in a!flatten() to get around this).
a!localVariables( local!array: { 1, 2, 3, 4 }, a!forEach( local!array, if( fv!item = 3, {}, fv!item ) ) /* reject(fv!item=3, local!array) */ )
Result:
Yeah, Mike, I find myself reflexively wrapping a!forEach in a!flatten() a lot.
It's worth it to be able to completely weed out all calls of reject().