From the course: Make SwiftUI Playgrounds Applications
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
More if{}else{} - Swift Tutorial
From the course: Make SwiftUI Playgrounds Applications
More if{}else{}
- [Steven] Last time we learned the if else. Let's expand on that knowledge with more about if else. In our coach so far we've learned several nest comparisons. Each makes only one comparison. What if we wanted to look at two conditions, not one? For example, what if pizzas a size 14 to 18 were to be marked on sale? We need to find pizzas bigger or equal to 14 and less than or equal to 18. For these kinds of comparisons we have three logical operators. The first operator is AND. For condition to be true both sides of the AND must be true, this is our case. And so I can make a compound boolean operator here to take care of that. So I can put if size is greater than or equal to 14 and size is less than or equal to 18. And then inside my brackets, I'm just going to put print On Sale. All right, now right now I have a 25 pizza as we can see here in size. I'm going to run the code here and I get an area of 625 in a large…
Contents
-
-
First steps8m 56s
-
(Locked)
Constant and calculations7m 57s
-
(Locked)
Functions, methods, and modifiers7m 14s
-
(Locked)
HStack, VStack, and layout9m 41s
-
(Locked)
Create new files and views4m 50s
-
(Locked)
Add images10m 10s
-
(Locked)
Learn about Swift types9m 32s
-
(Locked)
Variables and scope10m 33s
-
(Locked)
Using if{}else{}8m 24s
-
(Locked)
More if{}else{}12m 46s
-
(Locked)
Create custom functions7m 58s
-
(Locked)
Structs and classes10m 55s
-
Models and views10m 37s
-
-
-