If test with Empty list

Is this a bug?
If%20Test
I want to return a list if a condition is met, or an empty list if it fails.
The IF node works as expected if I pass two lists to it, but if I make one of the inputs an Empty.List, if returns Empty regardless of the test.
If%20Test%20Empty
If Test.dyn (3.5 KB)

The If node can’t take null or empty lists. You can use one of the custom If nodes to get around this or build your own.

You can use indices to select an empty list for you. Use an if statement to return 0 or 1 then use GetItemAtIndex to get the resultant value from a combined list using those indices.

1 Like

Thanks, Nick. Your trick worked.

That Empty List limitation seems like it’s kind of a big deal. I couldn’t find any documentation on that.

@DaveP

Use a ScopeIf instead. If you using a IF , lists you passing have to be of the same length

image

2 Likes

I would be careful about scopeif if you are to use it in a larger workflow, then scopeif+ from the clockwork package is more stable, as the scopeif is a history in itself.

2 Likes

i rather use the ternary form of ifs, instead of using a specific node for that.
For instance, you could write it like this:
a == true ?
{}:
1…3;

The question mark is for the test, the : is for the true result, and the ; is for the false result

1 Like

Thank you very much … it has served me a lot … I was very tangled and with your instructions I was able to get out of the abyss