Learn Swift for Beginners 2026 - Lesson 7 - If, Else If, Else

CodeWithChris Guide 2 months ago

Description

In this Learn Swift tutorial, you'll learn how to use if statements, else if, and else to make decisions in your code. This is one of the most important concepts when you learn Swift — writing logic that responds to true or false conditions.

Resources:
📚 Full guide:
https://codewithchris.com/learn-swift?utm_source=youtube&utm_medium=video&utm_campaign=learn_swift_lesson_7

What you'll learn:

- How if, else if, and else work together in Swift
- Why only the first true branch gets executed
- Different forms of if statements (if only, if/else, if/else if/else)
- How to write nested if statements
- Xcode's auto-indent shortcut (Control + I)
- A hands-on challenge: build a temperature checker
- Whether you're just getting started or brushing up on the basics, this lesson makes Swift conditionals easy to understand with clear examples and a coding challenge to test your skills.

Timestamps:
0:00 Introduction & Recap of Comparison Operators
0:40 Making Decisions with True/False Results
1:01 Intro to if, else if, else Keywords
2:00 Reading Output, Skipping False Branches
2:10 else if Branches Explained
3:06 Key Behavior: First True Branch Wins
4:03 Different Forms of if Statements
5:27 if, else if, and else Together
5:59 Nested if Statements
6:23 Xcode Auto-Indent Tip
7:23 Challenge: Temperature if Statement
8:10 Hint: Work from Coldest to Hottest
8:23 Live Coding the Challenge
11:05 See You in the Next Lesson

#SwiftProgramming #SwiftTutorial #LearnToCode