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
22 documented Misconceptions

Check Yourself
Misconception
BaseCaseNotNeededJava
Recursive computations do not necessarily need a base case
Misconception
BaseCaseNotNeededScratch
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
ConditionalIsSequenceScratch
If-then-else block is equivalent to sequence of two if-then blocks
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
ElseAlwaysExecutesScratch
The else branch of an if-then-else block 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
RecursiveFunctionNeedsIfElsePython
A recursive function needs to contain an if-else statement
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.