Learn
Conditional Expressions
Review
Great job getting to the end of this lesson. Let’s review the content we learned:
- Conditional expressions control the flow of execution in a program.
- An
if
expression executes a block of code when the value of its condition istrue
. - An
else
expression executes code when none of the previous expressions have atrue
value. - Comparison operators like
>
,<
,>=
, and<=
are used to compare two values to determine atrue
orfalse
value. - The
==
operator checks if two values are equivalent while the!=
operator checks if two values are not equivalent. - The logical AND operator (
&&
) returnstrue
when two Boolean expressions being compared are bothtrue
. - The logical OR operator (
||
) returnstrue
when at least one Boolean expression being compared istrue
. - The logical NOT operator (
!
) negates the value of a Boolean expression. else
-if
expressions are used to add more conditions to a traditionalif
/else
statement.- A nested conditional is a conditional that appears inside of another conditional.
- A
when
expression evaluates the value of a variable or expression in order to dictate the flow of a program. - The range operator
..
creates a consecutive succession of values.
Instructions
Use the space in Review.kt to practice the content learned in this lesson.
When you’re ready to move on, click Up Next.