Welcome back in the last video, we looked at if statements and I wanted to give you another example
of if statements and this time with a different type because we used integers and we compared integers
and you can even see that it says I should change that to a when statement.
So is simplify this expression.
And if I hover over it's a cascade, it should be replaced with when and I told you that we would look
at when expressions in this video, but we're going to do that in the next one because I want to do
a little more on if statements because, for example, I want to create this variable called name and
I'm going to set the value to Dennis.
So now I want to show you how to use if statements with strings and other data types.
So if name is equal, equal Dennis, then.
I want to write something like Welcome Home.
So print line.
Welcome home, Dennis.
All right.
But else I want to say, who are you, for example?
OK, so this is something that we can also do, so we can check strings as well.
What's important is that whatever is within those brackets can be either true or false.
So it has to be a Boolean that will be the result of whatever is within the brackets.
So the simplest form would be we have a variable here is rainy is true, for example.
So now it's raining and now I can check if it is rainy is true, then do some cold so print and it's
rainy, even though here of course, it's complaining.
Or it says the condition is always true.
So is rain will always be true because it's a vowel, so it can never be changed.
We changed it to Avar than it at least can be changed.
So now this warning is not there anymore, but you can see this is another way of doing if statement.
So the important part is that whatever is within the brackets can be either true or false.
So is a Boolean in the end.
Another important aspect of if statements that I haven't covered yet is the following if we look at
this if statement here, we can see that it says age greater equal to one.
And here it says age greater equal 18.
So this statement is true if that statement is also true, or let's say this statement here is true
if that statement here is true.
So what this means is that even though the statements on their are also true, we first of all, look
at the first one.
And if that one is true, then we ignore all the other ones.
That is something very important about if statements, because they always only look at the first expression.
If it's true and if it's not true, then it starts to look at the next expression.
Then at the next one.
And if none of the expressions are true, then the ALS blog is executed.
So it's not like all of them will be executed if the age is greater than 16, because all those three
would be true, right?
But only the first one, and that is generally true for if statements.
So it always goes top to bottom, which means first line to the last line of this statement.
And this is a whole if statement blocks.
So they're all interconnected to each other, which means that this ALS block really depends on all
of the other.
If an 11 blocks to be false.
Otherwise, it will never be executed.
All right, so I'd say let's go to when expressions and see how they are different too, if statements,
so see you in the next video.