Basic Syntax

Ternary Operator

English

Overview

An operator that simplifies an if statement, letting a condition be written in one line.

Details

An operator in the form 'condition ? A : B' that lets an if-else be written as a concise expression. Nesting it hurts readability fast, which is why many style guides limit it to a single level and recommend if-else for anything more complex.

More Programming terms