The ternary operator is a conditional expression in several programming languages in the following form (with some variations)
a ? b : c
meaning if a
is true, the expression evaluates to b
and otherwise to c
. Can be read as “if a
then b
, else c
”