Welcome back.
In the last year, 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 one statement.
So to simplify this expression, and if I hover over it to 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 a 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 will 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 ranie is true, for example.
So now it's raining and now I can check.
If it is raining is true, then do some cold.
So.
Prindle And it's raining, even though here, of course, it's complaining or it says the condition
is always true.
So it is raining will always be true because it's a vowel so it can never be changed.
If we change it to AVAR then 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 statements that I haven't covered yet is the following.
If we look at this statement here, we can see that it says Age Greater Equal 21, and here it says
age greater, equal 18.
So the 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 underneath 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 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 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 blog really depends on all of the
other if and elusive blocks to be false.
Otherwise it will never be executed.
All right, so I'd say let's go to one expressions and see how they are different to if statements.
So see you in the next video.