From the course: Programming for Non-programmers: iOS 17 and Swift 5
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Using conditional statements and Booleans
From the course: Programming for Non-programmers: iOS 17 and Swift 5
Using conditional statements and Booleans
- [Instructor] Now let's get some practice writing a conditional statement inside of a playground. Remember, you can create the playground by going to file new and choosing playground. Once you've done that, hit the run button and then you should see the output over on the right. Let's go down a few lines and type the word "if". Remember, this is what we do to create a conditional statement and then we need something that is evaluated as true or false called a condition. So let's see if greeting is equal to something else. So type greeting, as you start typing it, just use the code hinting and press return and then space and two equal signs. Remember two equal signs is the comparison operator. We're checking to see if one value is equal to another value. That's different from the assignment operator, which is one equal sign that we see here on line three. So let's just copy and paste this string on line three including the double quotes, and then I'm going to paste it after the double…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Understanding conditional statements4m 21s
-
(Locked)
Using conditional statements and Booleans4m 50s
-
(Locked)
Handling the numeric button presses4m 45s
-
(Locked)
Optionals and If Let statements3m
-
(Locked)
Enums5m 4s
-
(Locked)
Challenge: Conditionals2m 49s
-
(Locked)
Solution: Conditionals1m 51s
-
(Locked)
-
-