What's up my peeps.
Mark Bryce you're at DEF slopes dot com in case you've forgotten.
And here there's so my courses you're going to hear that a lot.
That's OK.
You're going to learn to love it.
I've had some people who are like oh this rock and roll music it's driving me crazy.
You do it over and over and over again.
But then everyone else is like this is so cool.
Gets me motivated gets me excited gets the energy going because most of you guys are like doing this
after work at night time.
I'm doing it here near midnight.
You've got to have something to wake you up and excite you about coding.
If you find coding boring it doesn't have to be.
OK.
So that's my inspiration for the hour of course of course.
This lesson is 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 and we're going to talk
about logical operators today.
We've talked about booleans wrote it we've talked about if statements and 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 this is what I want you to do.
Be like hey you want to see my logical operators.
Your day is going to be like this guy's awesome and this girl'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 bulls and comparisons.
Well call us logical operators.
A new folder.
Here we go.
OK.
So again we've talked about true and false and everything else.
Let's talk about how to make decisions and more decisions how to make more better decisions and one
more I wanted to reemphasize on was that your unary operator.
It's also a logical NOT operator.
If that makes any sense so logical NOT operator necessarily sexually the way you say it.
It's also a urinary urinary prefix operator.
Again those are just some terms for you there.
So what is that.
Well let let's say allowed entry equals false.
And there you go.
It's like giving us an air.
And so let what is let let is a constant It means it cannot be changed so I cannot say allowed entry
equals true.
OK so you've got variables and you've got constants 1 you can change one you can't change it's all you
got to know about it.
Pretty simple.
OK.
So loud and true equals false.
You can't get it right you can't get in the building.
So if not allowed entry print access denied.
All right so logical 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 asked 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 are actually five more characters
than 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 ok and go ahead and
do it.
From now on you can feel free to do this.
It's not equal to true but that the operator is a quick shorthand way to say not ok.
If this is not true.
OK so that makes sense.
OK.
Just emphasizing that you're going to see a lot in other people's code.
A step further.
OK.
Let again Constance you always want to use constants whenever you're not going to change the value if
you are going to change the value is a variable but if you know you're not going to change the value.
Use a constant memory optimize.
Ok so very important news constants at all possible entered door code.
Oh OK.
Now we're entering a door.
Code equals true.
OK.
And let's say there's also a retina scan like it's like Metal Gear Solid ok past retina scan was false.
You know some high tech stuff you know or that game you'd like go and then back the original very first
one.
Is this the cause of the mall.
I think you go knock on the crate and that really dumb A I would come running around and then after
they felt like the noise was no longer threatening they would just chill
irrelevant.
OK.
When it's midnight when you're making videos at midnight you can say whatever you want.
And when you got all these people watching you.
It's how it's going to be.
Try and stop me.
Camera.
He doesn't see me here.
Maybe if you were here what we're going to do is some We're going to use logical operators to make some
decisions so let's say we want the user where the person is 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 past retina scan.
OK we're going to print welcome however.
However
remember the movie Mission Impossible like they're reviewing You know 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 door code and you do a retinal scan but so I say let.
I am Tom Cruise from Mission Impossible.
So if entered door code and past retina scan or if I am Tom Cruise for Mission Impossible then we can
get in print welcome and sure enough.
Mission Impossible Tom Cruise is in the door but of course I am not Tom Cruise.
So this is what does this here.
This is the logical or OPERATOR OK so what's going to happen is the right side is going to be calculated
first here.
OK.
All right.
And so if this is true OK.
It's going to see this or operator and then it doesn't even care about this guy.
If this is true because or means one or the other has to be true.
So this side's going to get run.
And if that's true great otherwise or let's run this and then we do.
If this is true and if this is true.
OK.
So then we so we're at what we're saying here is hey both of these have to be true using the and operator
here.
So this is or this is.
And OK.
This is why it was printing when he was Tom Cruise.
Right.
Because the one on the right was true.
And we didn't really care about this woman the left over here.
So pretty cool huh.
Also of course.
So access is of course access is denied because we haven't passed the retina scan yet.
OK.
So else or if you don't know the door code and you pass ran a scan or if I'm Tom Cruise for Mission
Impossible or in else print
access denied again.
So access denied again.
All right so what we've done here is before we just did NOT operator here we're doing it and operate
I mean these both have to be true.
We also used an OR operator.
So ORP your mission and Tom Cruise.
Mission Impossible you're going to climb through and you're going to fall down to the roof and you don't
need the retina.
You don't need a friggin rottenness.
All right.
So cool stuff right.
And let's do one more example of the OR operator here and say LET has the door key equals false
so has Dorcy was false let knows over password equals true.
And what we can do this is kind of like the Tom Cruise example right if has Dorcy or if knows override
password and prints.
Well same thing or one or the other the right one is going to be processed first this knows my password
and this is true then it doesn't mean to do anything with the left hand side if it is false and it's
going to move to the left hand side over there.
OK else
you still ain't getting in to for whatever.
Right.
And or.
OK.
Pretty cool right.
So with these logical operators you can use parentheses there.
You don't need to get optional but sometimes they help with readability.
OK like this right here.
This helps me get the let me know that this is going to kind of run together.
And this is over here.
Sometimes people like to do that.
You don't need to of course but they do work on that just fine.
And we did used to and and as well as that or over here you can use logic operators in the same line.
Really cool stuff you're going to use these a lot when you're making conditional you know conditional
logic.
That's how all programs are run.
You know and this is a perfect example right here.
If you were actually building an app to well let's say you know 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 you know.
So if the thumb print worked or you know if it detected your face you know then you're in you know lots
of different options here and these are real real world examples that we're using here so logical operators
are going to use them every single day it's going to take practice doing this here in the playground.
It's OK but when you are actually building apps it's really going to start to sink in.
So really good stuff plowing along here in foundationless.
Hope you're learning a lot.
Marc price upstrokes.