** Next:** repeat
** Up:** Control Structures
** Previous:** if, elif, else
** Contents**
** Index**

##

ternary conditional

*a* `?` *b* `:` *c*

The ternary conditional operation, familiar from the C programming
language, is supported. In this construct, the ``?`' and ``:`' are literal, the *a*, *b*, and *c* are
expressions. If *a* evaluates as `true`, then *b* is
evaluated and the construct returns its result. Otherwise, *c* is
evaluated and the construct returns that result. Hence, the form

`x = a ? b : c
`

is equivalent to

if (a)
x = b
else
x = c
end

The ```true`'' condition depends on the type of variable
represented by *a*, as for the `if` operator. For example,
the following are `true`:

- A nonzero numeric value. This includes the result of a
conditional expression when the condition is satisfied.

- An active handle.

- A non-empty zoidlist (a layer expression is evaluated to obtain
a zoidlist).

- A non-null string.

Stephen R. Whiteley
2018-01-11