GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

DAY 5

Conditions


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.

How can this day be improved?

Great job on finishing another day! If you still have questions about what you learned, please send them in using this form – I'll do my best to address the most common problems in the next course update. Thank you!

Now share your progress…

If you use Twitter, the button below will prepare a tweet saying you completed today, along with a celebratory graphic, the URL to this page, and the challenge hashtag. Don't worry – it won't be sent until you confirm on Twitter!

Alternatively, copy and paste the text below to your preferred social network - I'm @twostraws on Mastodon.social, Bluesky, and Threads.

🎉 I just finished Day 5 of the #100DaysOfSwiftUI at https://www.hackingwithswift.com/100/swiftui/5 via @twostraws

Need help? Tweet me @twostraws!

 

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's all new Paywall Editor allow you to remotely configure your paywall view without any code changes or app updates.

Click to save your free spot now

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.