Conditionals & Logic
Learn how to develop complex programs in Swift with conditionals and logical operators.
StartKey Concepts
Review core concepts you need to learn to master this subject
if
Statement
else
Statement
else if
Statement
Comparison Operators
Ternary Conditional Operator
switch
Statement
switch
Statement: Interval Matching
switch
Statement: Compound Cases
if
Statement
if
Statement
var halloween = true
if halloween {
print("Trick or treat!")
}
// Prints: Trick or treat!
An if
statement executes a code block when its condition evaluates to true
. If the condition is false
, the code block does not execute.
Conditionals
Lesson 1 of 2
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory