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++:

int a = 15, b = 10
int max = ?(a > b; $[a]; $[b])

console(max)

int a = 15, b = 10

`?(a > b; a; b) := 20`
console(a)

n++ example

Examples of ? being used with n++:

@int(a = 15, b = 10)
@int(max = ?(a > b; $[a]; $[b]))

@console(max)

@int(a = 15, b = 10)

@`@?(a > b; a; b) := 20`
@console(a)

@exprtk(?(a > b; a; b) := 30)
@console(a)