Ternary operator - HiStructClient/femcad-doc GitHub Wiki
Syntax for basic conditional expressions. An expression a ? b : c evaluates to b if the value of a is true, and otherwise to c.
(condition) ? (true) : (false)
A := 2
B := (A > 0) ? (True) : (False)
gives
B := true
A := [1, 2, 3, 4, 5, 6, 7]
B := A.Select( i => (i < 5) ? (0) : (i))
gives
B := [0, 0, 0, 0, 5, 6, 7]
For INEQUALITY condition, use != sign:
Result := (20 != 25) ? (True) : (False)
gives
Result := False
(condition 1) ? ((condition 2) ? (true 2) : ((condition 3) ? (true 3) : (false 3))) : (false 1)
note: e.g. false 2 is in the above code either true 3 or false 3
Variable := (condition) ? (true result) : (false result) but in more complex syntax it is needed to put the whole expression into brackets ()
ResultExplanation := ( ( ResultCondition )
? ( "" )
: ( " ( Result= " + currentResultString + ", Expected= " + actualResultString + " )" ) )
Ternary operator uses for multiple conditions "lazy" evaluation. That means that it evaluates conditions "from left". And if there is a possibility to do fast evaluation, without knowing the right side evaluations, it does so. Typically:
TRUE or whatever = TRUE
FALSE and whatever = FALSE