-
Notifications
You must be signed in to change notification settings - Fork 0
Ternary operator
jpodval edited this page Aug 24, 2017
·
6 revisions
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]
(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 + " )" ) )
- Localisation
- Basics
- FemCAD workings
- Geometry
- Input
- Direct edit
- Analysis
- Output
-
Stories
- FAQ
- Stupid user mistakes
- How to discover speed issues in the code
- How to run script faster
- How to list evaluated variables
- How I got lost in graphical interface when dealing with labels
- How to create Bill of material
- How to deal with point transfer between UCS and LCS
- How to define input
- How to make output