Conditional

In a conditional statement or expression the value of a condition determines which alternative pieces of code to execute.

Related concepts:  StatementExpressionControl Flow

Closest Wikipedia entry:  Conditional (computer programming) — In computer science, conditionals (that is, conditional statements, conditional expressions and conditional constructs,) are programming language commands for handling decisions. Specifically, conditionals perform different computations or actions depending on whether a programmer-defined boolean condition evaluates to true or false. In terms of control flow, the decision is always achieved by selectively altering the control flow based on some condition (apart from the case of branch predication).

Misconceptions about Conditional
18 documented Misconceptions

Check Yourself
Misconception
BaseCaseNotNeededJava
Recursive computations do not necessarily need a base case
Misconception
ConditionOneOutEdgeJava
A condition node in a control-flow graph can have a single outgoing edge
Misconception
ConditionalIsSequenceJava
If-else is equivalent to sequence of two ifs
Misconception
ConditionalIsSequencePython
If-else is equivalent to sequence of two ifs
Misconception
ConditionalOperatorNotExpressionJavaScript
The conditional operator is not an expression
Misconception
ElsIfJava
There is an elsif keyword for multi-way conditional statements
Misconception
ElseAlwaysExecutesJava
The else branch of an if-else statement always executes
Misconception
ForIsConditionalJava
The body of a for statement executes at most once
Misconception
IfIsLoopJava
The body of an if statement executes repeatedly, as long as the condition holds
Misconception
IfIsLoopPython
The body of an if-statement executes repeatedly, as long as the condition holds
Misconception
IfRequiresElseJava
Every if statement requires an else
Misconception
LoopTerminatingConditionJava
For and while loops end when the condition becomes true
Misconception
MapToBooleanWithConditionalOperatorJava
To map a boolean expression to a boolean, a conditional operator is necessary
Misconception
MapToBooleanWithIfJava
To map a boolean expression to a boolean, an if statement is necessary
Misconception
MapToBooleanWithIfPython
To map a boolean expression to a bool, an if statement is necessary
Misconception
MapToBooleanWithTernaryOperatorPython
To map a boolean expression to a bool, a ternary conditional operator is necessary
Misconception
RecursiveMethodNeedsIfElseJava
A recursive method needs to contain an if-else statement
Misconception
StatementMultipleOutEdgesJava
A non-condition node in a control-flow graph can have multiple outgoing edges

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.