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{}

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