Module 5 · Decisions
The Ternary Operator, and Conditions Worth Naming
Free with an accountReading
Zara wrote the gym's door message as one line of code. It had three question marks, three colons and three conditions, and it worked.
Checking what this lesson needs for you…
What is inside The Ternary Operator, and Conditions Worth Naming
- The ternary is an expression, so it has a value
- A value, never an effect
- The one idiomatic use: a choice inside printf
- No nesting: name the condition instead
- The type of a ternary comes from both arms