Back
Close

Definition

In programmation, conditional expressions are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false.

The if–then-else construct is common across many programming languages. Although the syntax varies quite a bit from language to language, the basic structure (in pseudocode) looks like this:

If (boolean condition) Then
     -- do some stuff
Else
     -- do other stuff
End If

When an interpreter finds an If, it expects a boolean condition – for example, x > 0, which means "the variable x contains a number that is greater than zero" – and evaluates that condition. If the condition is true, the statements following the “then” are executed. Otherwise, the execution continues in the following branch – either in the else block (which is usually optional), or if there is no else branch, then after the end If.

Source: Wikipedia (license)

External resources

ConditionsTernary operator