NEW: Learn to build amazing SwiftUI apps for macOS with my new book! >>



If there’s one line from Shakespeare’s Hamlet that most people know, it’s “to be or not to be, that is the question.” Shakespeare meant that as the ultimate question of life or death, but it just so happens that Hamlet strikes right at the heart of logic in programming: evaluating whether a condition is true or not.

Today we’re going to get into the real detail of Swift: operators and conditions, which let us evaluate our program’s state as it runs and take different action depending on the result. There are several ways of doing it and you’ll need them all, but we’ll walk through them step by step so you can see how they compare.

Today you have four tutorials to work through, where you’ll meet things like if, switch, and more. Once you’ve watched each video and optionally gone through the extra reading, there’s a short test to help make sure you’ve understood what was taught.

  1. How to check a condition is true or false
  2. How to check multiple conditions
  3. How to use switch statements to check multiple conditions
  4. How to use the ternary conditional operator for quick tests

Do you remember the two rules of this series? You’re already being awesome at the first one because you keep coming back for more (you rock!), but don’t forget the second: post your progress online, so you can benefit from all the encouragement.

Have some questions about operators and conditions?

Hit Send below to start a virtual conversation with me.

Need help? Tweet me @twostraws!


Hacking with Swift is sponsored by Fernando Olivares

SPONSORED Fernando's book will guide you in fixing bugs in three real, open-source, downloadable apps from the App Store. Learn applied programming fundamentals by refactoring real code from published apps. Hacking with Swift readers get a $10 discount!

Read the book

Sponsor Hacking with Swift and reach the world's largest Swift community!

100 Days of SwiftUI

The 100 Days of SwiftUI is a free collection of videos, tutorials, tests, and more to help you learn SwiftUI faster. Click here to learn more, or watch the video below.

Back to 100 Days of SwiftUI

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.