What does this Codeblock do?

Hello,

what does this codeblock do? it is a dictionary? or a “if” condition? do i merge lists?

L1<=3? L1:L2;
L1==3? L1:L2;
L1==""? L1:L2;
L1!=""? L1:L2;

KR

Andreas

That Code Block contains four standalone if-statements, nothing more.

3 Likes

Hello, I saw a few days ago

Cordially
christian.stan

1 Like

search for and replace …

if this do that …

Ok!

Thats the ternary form of an if-condition. Nearly all programming languages do have this short form of an if-condition.

1 Like

Some trivia: I use Revit 2019 (due to work) and I noticed that if you use the ternary form you have to be aware of this:

If your true-value or false-value can be null it won’t work, eventhough if the condition is chosen in a way that it only would output the value that is not null. Its like dynamo wants so be prepared for both cases and therefore checks both values to be not null.
Workaround:

  1. Use normal if-condition
  2. hide the possible null-value inside of a function

I don’t know if this problem still occurs in newer version of Revit.