The IF node doesn't work with empty lists

Hello,

I am trying to use the “if” node to get a text if the list is empty (true), and the list itself if not (boolean false). When i try the node with a not empty list, it works well, but with an empty list, it just keeps giving me “Empty list”, even if the boolean is true.
Can you help me with this issue ?

try to use “scope if” instead

I tried with scopeif already but Dynamo crashes when the boolean is “false”.

In a code block try this:
indx = test ? 0 : 1;

[valueIfTrue, valueIfFalse][indx];
1 Like

Hello RimT,

I have uploaded my solution to this issue and speculated what may cause the problem.
My understanding is:

  1. Not just the IF node but, I guess, almost all of the nodes does not work with an empty list.
  2. When a note fed an Empty List, the node returns Empty List outright.

Thank you for bringing this peculiar issue. I hope I was helpful.The_IF_node_does_not_work_with_empty_lists.dyn (33.9 KB)

It worked, thank you for your help

Thank you for your help, i will use @jacob.small’s solution because it’s shorter. But yours can work too.