fn: ?
[contents]

Contents

Syntax

The syntax for ? calls is:

f++:  
?{options}(condition; expression_1; expression_2)

n++:  
@?{options}(condition; expression_1; expression_2)

Description

The ? function implements a ternary operator, if the condition evaluates to 1 then the first expression is evaluated, otherwise the second expression is evaluated.

Options

The following options are available for ? calls:

option description
f++ evaluate expression with f++
n++ evaluate expression with n++
o return output
!o do not return output
option description

f++ example

Examples of ? being used with f++:

  1. int a = 15, b = 10
  2. int max = ?(a > b; $[a]; $[b])
  3.  
  4. console(max)

  1. int a = 15, b = 10
  2.  
  3. `?(a > b; a; b) := 20`
  4. console(a)

n++ example

Examples of ? being used with n++:

  1. @int(a = 15, b = 10)
  2. @int(max = ?(a > b; $[a]; $[b]))
  3.  
  4. @console(max)

  1. @int(a = 15, b = 10)
  2.  
  3. @`@?(a > b; a; b) := 20`
  4. @console(a)
  5.  
  6. @exprtk(?(a > b; a; b) := 30)
  7. @console(a)