What's up my peeps? Mark Price here at Devslopes.com in case you've forgotten. If you're new to Devslopes and due to my courses, you're going to hear that a lot. That's okay. You're going to learn to love it. Some people who are like it's rock and roll music. It's driving me crazy. You do over and over again, but then everyone else is like this is so cool, it gets me motivated, it gets me excited, it gets the energy going cause most of you guys are doing this after work, at night time. I'm doing it here near midnight. You've got to have some to wake you up and excite you about coding. If you find coding boring, it doesn't have to be. Okay. So that's my inspiration for the hour. First courses. This lesson's not going to be that long. I hope we are going to go ahead and get started with the playground, and today we're going to finish our discussion on making conditional decisions. We're going to talk about logical operators today. We've talked about Boolean already. We've talked about if statements and else statements. Those are called conditionals. Now we're going to talk about logical operators. So Logical Operators. All right. Next time you go out on a date, this is what I want you to do. Be like, hey, do you want to see my logical operators? Your date's going to be like, this guy's awesome, this guy's cool. Serious do it all the time. All right. Don't do that. All right here we go. So I'm going to go here into our bools and comparisons. Well, let's call this logical operators. A new folder. Here we go. Okay. So again, we've talked about trues and falses and everything else. Let's talk about how to make more decisions. How to make more better decisions and one more I wanted to re-emphasize on was that urinary operator. It's also a logical NOT operator if that makes any sense. So logical NOT operator that's actually the way you say it. It's also a urinary prefix operator. Again, those are just some terms for you there. So what does that? Well, let's say allowed entry equals false okay, and there we go. It's giving us an error. So what is a let? Let is a constant. It means it cannot be changed. So I cannot say allowed entry equals true. Okay. You've got variables and you've got constants. One you can change one you can't change. It's all you got to know about it. Party thing simple. Okay. So allowed entry equals false okay. You can't get in right. You can't get in the building. So if not allowed entry, print access denied. All right. So logical NOT operator. What it's really saying is, it's the opposite of this more or less. So if allowed entry is true, well we're not doing that check. We're saying if allowed entry is not true. So this would be the exact same thing as writing if allowed entry is not equal to true. That's the exact same thing except this is a little more writing right one, two, three, four, five, six different characters that you have to write or actually five more characters that you'd need to write on there, plus the space anyway and it's long. So when you become a more veteran programmer, you're going to start using this a lot more. Sometimes it makes sense to say this when you're new because it's easier to read okay, and go ahead and do it. From now on you can feel free to do this if it's not equal to true. But the NOT operator is a quick shorthand way to say not okay. If this is not true okay. Does that make sense? Okay. Just re-emphasizing that you're going to see a lot in other people's code. A step further. Okay. Again, the constants, you always want to use constants whenever you're not going to change the value. If you are going to change the value, use a variable. But if you know you're not going to change the value, use a constant. Its memory optimized. Okay. So very important these constants at all possible. Entered Door code. Okay. So now we're entering a door code equals true. Okay. Let's say there's also a retina scan. It's like metal gear solid here okay. Passed retina scan equals false. Some high-tech stuff. Like that game you'd like go and then the original very first one is just the coolest of them all. I think you'd go you'd knock on the crate and the really dumb AI would come running around, and then after they felt like the noise was no longer threatening, they were just chill. Clearly irrelevant. Okay. When you're making videos at midnight, you can say whatever you want and when you've got all these people watching you. How it's going to be? Try and stop me Camera. He isn't even here. Maybe if you were here. What we're going to do is, we're going to use logical operators to make some decisions. So let's say we want the user or the person who's coming in to enter the door code and pass the retina scan. So what we're going to do is we're going to say, if entered door code and passed retina scan. We're going to print, welcome. However, remember the movie Mission Impossible? They're reviewing the CIA bunker and how to get in the guy has to go through all the steps of the retinal scan. They knew that they couldn't do it. So this is the way you do it. You enter a door code and retinal scan, but let's say let, I am Tom Cruise from Mission Impossible. So if entered door code and pass retina scan or if I am Tom Cruise for Mission Impossible, then we can get in. Print welcome. Sure enough Mission Impossible Tom Cruise is in the door, but of course, I am not Tom Cruise. So what is this here? This is the logical OR operator. Okay. So what's going to happen? Is the right side is going to be calculated first here. Okay. All right. So if this is true okay, it's going to see this OR operator and then it doesn't even care about this. Okay. If this is true. Because OR means one or the other has to be true. So this side is going to get run and if that's true great otherwise, or let's run this. Then we do if this is true and if this is true. Okay. So what we're saying here is, both of these have to be true using the AND operator here. So this is OR, this is AND. This is why it was printing when he was Tom Cruise right. Because the one on the right was true and we didn't need to care about this one on the left over here. So pretty cool. Of course, access is denied okay because we haven't passed the retina scan yet. Okay. All right. If you enter the door code and you pass the Retina scan or if I'm Tom Cruise for Mission Impossible, we're in. Else, print access denied again. Okay. So else print access denied again. All right. So what we've done here is, before we just did a NOT operator, here we're doing an AND operator, these both have to be true. We also used an OR operator. So OR your mission in Tom Cruise Mission Impossible, you're going to climb through and you're going to fall down through the roof, and you don't need the freaking retina scan. All right. So cool stuff right? Let's do one more example of the OR operator here. Okay. We're going to say Let has door key equals false. So has door key equals false. Let knows override password equals true. Okay. Then what we can do, this is like the Tom Cruise example right. If has door key or if knows override password, then prints welcome. Okay. Same thing or one or the other. The right ones going to be process first this knows override password. If this is true, then it's doesn't even to do anything with the left-hand side. If it is false, then it's going to move to the left-hand side over there. Okay. Else, you still ain't getting in through fool. Right. So AND, OR okay. Pretty cool right. So with these logical operators, you can't use parentheses there. You don't need to. Okay. They're optional, but sometimes they help with readability okay like this right here. This let me know that this is going to be run together. This is over here. Sometimes people like to do that. You don't need too of course. But they do work on that just fine. We did use the AND as well as the OR over here. Okay. You can use logical operators in the same line. Really cool stuff. You're going to use these a lot when you're making conditional logic. That's how all programs are run and this is a perfect example right here. If you were actually building an app, let's say even some phone apps or phones like they now have retinal scanning and stuff like to unlock the phone or even on the iPhone, you can use your thumb. So if the thumbprint worked or if it detected your face, then you're in. There is a lots of different options here. These are real world examples that we're using here. So logical operators, you're going to use them every single day. It's going to take practice doing this here in the playground, it's okay. But when you start actually building apps, it's really going to start to sink in. So really good stuff plowing along here in foundational swift. Hope you're learning a lot. Mark Price at Devslopes.com. See you soon.