1
00:00:00,470 --> 00:00:01,290
Welcome back.

2
00:00:01,310 --> 00:00:07,600
In the last year, we looked at if statements, and I wanted to give you another example of if statements

3
00:00:07,610 --> 00:00:12,350
and this time with a different type, because we used integers and we compared integers.

4
00:00:12,350 --> 00:00:18,020
And you can even see that it says I should change that to a one statement.

5
00:00:18,020 --> 00:00:24,440
So to simplify this expression, and if I hover over it to Cascade, it should be replaced with when

6
00:00:24,830 --> 00:00:27,980
and I told you that we would look at when expressions in this video.

7
00:00:28,190 --> 00:00:33,470
But we're going to do that in the next one because I want to do a little more on if statements because,

8
00:00:33,470 --> 00:00:40,360
for example, I want to create a variable called name and I'm going to set the value to Dennis.

9
00:00:40,910 --> 00:00:46,120
So now I want to show you how to use if statements with strings and other data types.

10
00:00:46,250 --> 00:00:50,810
So if name is equal, equal Dennis, then.

11
00:00:51,830 --> 00:00:59,060
I want to write something like Welcome home, so print line will welcome home, Dennis.

12
00:00:59,990 --> 00:01:07,070
All right, but else I want to say, who are you, for example?

13
00:01:07,760 --> 00:01:12,770
OK, so this is something that we can also do so we can check strings as well.

14
00:01:12,980 --> 00:01:19,430
What's important is that whatever is within those brackets can be either true or false.

15
00:01:19,460 --> 00:01:26,570
So it has to be a boolean that will be the result of whatever is within the brackets.

16
00:01:27,800 --> 00:01:36,930
So the simplest form would be we have a variable here is ranie is true, for example.

17
00:01:36,950 --> 00:01:39,740
So now it's raining and now I can check.

18
00:01:39,740 --> 00:01:44,080
If it is raining is true, then do some cold.

19
00:01:44,090 --> 00:01:44,330
So.

20
00:01:44,330 --> 00:01:52,010
Prindle And it's raining, even though here, of course, it's complaining or it says the condition

21
00:01:52,010 --> 00:01:53,010
is always true.

22
00:01:53,030 --> 00:01:56,570
So it is raining will always be true because it's a vowel so it can never be changed.

23
00:01:56,900 --> 00:02:00,060
If we change it to AVAR then it at least can be changed.

24
00:02:00,080 --> 00:02:03,440
So now this warning is not there anymore.

25
00:02:03,740 --> 00:02:06,770
But you can see this is another way of doing if statement.

26
00:02:06,790 --> 00:02:11,180
So the important part is that whatever is within the brackets can be either true or false.

27
00:02:11,720 --> 00:02:13,610
So is a boolean in the end.

28
00:02:15,630 --> 00:02:20,880
Another important aspect of statements that I haven't covered yet is the following.

29
00:02:20,880 --> 00:02:28,980
If we look at this statement here, we can see that it says Age Greater Equal 21, and here it says

30
00:02:28,980 --> 00:02:30,760
age greater, equal 18.

31
00:02:31,260 --> 00:02:33,950
So the statement is true.

32
00:02:33,960 --> 00:02:40,050
If that statement is also true or let's say this statement here is true, if that statement here is

33
00:02:40,050 --> 00:02:40,320
true.

34
00:02:40,740 --> 00:02:47,850
So what this means is that even though the statements on underneath are also true, we first of all

35
00:02:47,880 --> 00:02:48,900
look at the first one.

36
00:02:49,020 --> 00:02:52,740
And if that one is true, then we ignore all the other ones.

37
00:02:52,990 --> 00:02:59,520
That is something very important about if statements because they always only look at the first expression.

38
00:02:59,520 --> 00:03:06,180
If it's true and if it's not true, then it starts to look at the next expression, then at the next

39
00:03:06,180 --> 00:03:06,480
one.

40
00:03:06,750 --> 00:03:11,060
And if none of the expressions are true, then the blog is executed.

41
00:03:11,550 --> 00:03:18,690
So it's not like all of them will be executed if the age is greater than 16, because all those three

42
00:03:18,690 --> 00:03:19,380
would be true.

43
00:03:19,390 --> 00:03:19,730
Right.

44
00:03:20,160 --> 00:03:21,330
But only the first one.

45
00:03:21,720 --> 00:03:24,060
And that is generally true for if statements.

46
00:03:24,080 --> 00:03:29,700
So it always goes top to bottom, which means first line to last line of this statement.

47
00:03:29,880 --> 00:03:31,760
And this is a whole if statement blocks.

48
00:03:31,760 --> 00:03:38,670
So they're all interconnected to each other, which means that this blog really depends on all of the

49
00:03:38,670 --> 00:03:42,030
other if and elusive blocks to be false.

50
00:03:42,420 --> 00:03:44,220
Otherwise it will never be executed.

51
00:03:45,060 --> 00:03:51,200
All right, so I'd say let's go to one expressions and see how they are different to if statements.

52
00:03:51,210 --> 00:03:52,350
So see you in the next video.

