...

/

Conditional Expression

Conditional Expression

In this lesson, an explanation of what conditional expressions are, how to use them, and their basic syntax is provided.

We'll cover the following...

Introduction

A conditional expression is a concise way to write the equivalent of an if-else statement.

This kind of expression can help to produce highly readable assignment statements fitting onto one line of the source code.

Syntax

This is the syntax:

Press + to interact
( condition ) ? expressionIfTrue : expressionIfFalse;
  1. The condition is evaluated to see whether it ...