Skip to the content
Documentation

cond

No ratings yet

Summary

Returns the value of the first clause who's condition is TRUE.

Usage

cond( cond1, value1 [, cond2, value2 [, ... ] ] )

Parameters

Name Type Description Required
cond1 boolean Match condition 1. Yes.
value1 any Return value for condition 1. Yes.
cond2 boolean Match condition 2. No.
value2 any Return value for condition 2. No.

Returns

One of the provided values or FALSE.

Description

This operator evaluates the provided conditions (odd numbered parameters). If one of the conditions evaluates to TRUE then the value which is associated with that condition is returned. If none of the conditions are TRUE, the operator will return FALSE. If an odd number of parameters are provided, the operator will return the last parameter if all conditions fail.

Examples

Example 1
{cond( true(), 'apples', true(), 'bananas' )}

The following output will be produced: "apples".

Example 2
{cond( false(), 'apples', true(), 'bananas' )}

The following output will be produced: "bananas".

Example 3
{cond( false(), 'apples', false(), 'bananas' )}

No output will be produced, the operator will return FALSE.

Example 4
{cond( false(), 'apples', 'bananas' )}

The following output will be produced: "bananas".

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.