if

if .. then .. else .., ternary operator

The ternary operator if-then-else takes a Boolean as first argument, and two identically typed values as second and third arguments.

table T = with
  [| as A, as B, as C |]
  [| 1,    0,    true |]
  [| 2,    3,    false |]
  [| 4,    5,    false |]

show table "" a1d3 with
  T.A
  T.B
  T.C
  if T.C then T.A else T.B

In many languages (C, C++, Java, C#, ..), the ternary operator is written condition ? if_true : if_false.

See also