WEBVTT 00:00.950 --> 00:07.640 Welcome in his lecture, I'm going to show you as an elective branches, as I promised, and I'll talk 00:07.640 --> 00:10.190 about a few rules by using the if statement. 00:10.550 --> 00:11.500 OK, let's check it out. 00:12.910 --> 00:15.430 This used as statement with Disko. 00:16.680 --> 00:19.950 OK, now I'm going to type out with its own blog like this. 00:21.090 --> 00:27.090 As branch can only be used when there is an if statement, so you cannot use it without an if statement. 00:27.150 --> 00:33.480 All right, so anything declared in the if statements blog will be available in the blog, by the way, 00:33.630 --> 00:36.900 but not vice versa inside the ALS blog. 00:37.110 --> 00:38.940 I'm going to print LUL like this. 00:40.100 --> 00:40.700 OK, listen. 00:43.490 --> 00:45.500 It brings love, let me tell you why. 00:46.470 --> 00:51.750 Yes, because this condition expression of the if statement was false is simple as that. 00:53.400 --> 00:59.790 So as Esperance's block is executed instead, and it has printed low as a message, by the way, as 00:59.790 --> 01:04.380 Branch is only executed when the if statements, all the other branches were false. 01:05.010 --> 01:07.380 Let me show you what I mean by the other branches. 01:10.320 --> 01:14.110 I've simplified the program a little bit to keep things easier to understand. 01:14.130 --> 01:21.030 OK, I removed the valid variable from the statements condition sorry, but as Branch looks like a little 01:21.030 --> 01:23.380 bit ugly now, but I'm going to fix it in a minute. 01:23.400 --> 01:23.970 Nobody's. 01:25.210 --> 01:30.700 OK, let's say that you want to display a special message when the score is equal to three is in here. 01:31.880 --> 01:34.940 To do that, you need an as if statement like this one. 01:37.400 --> 01:43.870 As you can see here, as of Branch, it looks like an IV branch because it really is like the if statement. 01:43.880 --> 01:50.480 It has its own condition, expression only difference is that it starts with an ALS keyboard and it 01:50.480 --> 01:53.450 should belong to an if statement right after the IV branch. 01:54.670 --> 01:56.970 That's why it's called an active branch. 01:57.020 --> 01:59.220 Now, then, as if statements and. 01:59.950 --> 02:00.790 OK, Lieutenant. 02:04.990 --> 02:06.920 It brings on the age cool. 02:07.570 --> 02:09.690 Now let me explain what's going on here. 02:10.300 --> 02:12.990 The score is not greater than three, right? 02:13.600 --> 02:21.340 So the first if statement is skipped and then as if Branch's condition is checked, the score equals 02:21.410 --> 02:21.790 three. 02:21.820 --> 02:23.740 So two hours if Branch is executed a. 02:24.800 --> 02:31.190 And as Branch Downbelow escaped as well, that's because as condition was true. 02:32.230 --> 02:36.820 As I said, as branch only executed when all the branches are false. 02:40.500 --> 02:44.220 Now, here are initialise, the scorable with a value of two. 02:44.640 --> 02:47.700 OK, let's add one more active branch here. 02:48.310 --> 02:50.550 It'll execute Vänskä is two, right? 02:52.920 --> 02:53.670 OK, Lipman's. 02:54.910 --> 02:59.930 It brings Matt, it's because the score is two, that's not a good score anyways. 03:00.460 --> 03:03.970 Now, let's check out the rules of the IF statement. 03:04.940 --> 03:09.950 First rule is that you can use the F branch in an if statement only once. 03:11.070 --> 03:15.470 The second rule is that you can use as many active branches as you want. 03:15.600 --> 03:20.070 Sky is the limit as you seen, as if Branch is completely optional. 03:20.340 --> 03:21.720 You don't have to use it at all. 03:21.930 --> 03:28.950 And the last rule is that similar to olive branch you can use and as branch only once is, you seem 03:29.130 --> 03:33.030 like as if Branch as branch is also an optional branch. 03:33.480 --> 03:36.600 It runs only when all the previous branches were false. 03:37.440 --> 03:44.700 So in summary, that can be only one fifth and one as branch, but there can be multiple elusive branches. 03:45.090 --> 03:45.840 It's that simple. 03:46.790 --> 03:50.330 All right, that was all for now, see in the next lecture, the.