WEBVTT 00:02.080 --> 00:07.510 Welcome in his lecture, I'm going to talk about what is the Gotha statement and how to use it. 00:08.660 --> 00:15.470 By the way, go to is rarely used, so this lecture is completely optional, you can skip it if you 00:15.470 --> 00:15.800 want. 00:16.940 --> 00:24.080 OK, now let me talk about the go to statement briefly, first go to statement allows us to jump to 00:24.080 --> 00:30.170 a label within the same function you saw that you can use a break or a continuous statement to jump 00:30.170 --> 00:30.740 to a label. 00:30.920 --> 00:31.270 Right. 00:32.320 --> 00:38.590 However, they only work by use them inside the for statement or in a switch statement, on the other 00:38.590 --> 00:44.740 hand, go to statement doesn't have that restriction since the label belongs to a function. 00:44.740 --> 00:49.030 So it can be used from almost anywhere as long as you are inside the same function. 00:49.190 --> 00:49.570 OK. 00:50.570 --> 00:53.470 OK, let's take a look at an example to see how it works. 00:55.680 --> 00:59.760 Now, I'm going to create the loop without using the false statement, and instead I'm going to use 00:59.760 --> 01:03.730 I go to statement, this will show you how the goal, the statement works. 01:04.190 --> 01:07.020 OK, OK, let's be an interval now. 01:07.970 --> 01:12.440 Israel will store the current look index just like a four Staples index variable. 01:12.560 --> 01:12.910 OK. 01:13.770 --> 01:17.700 And after that, I'm going to declare a label name loop like this. 01:19.050 --> 01:22.350 Then just below that, I'm going to type and if statement like this. 01:23.640 --> 01:25.530 If I is less than three. 01:26.720 --> 01:33.050 OK, just like an ordinary loop is artificial loop first checks the condition and then decides whether 01:33.050 --> 01:34.720 to continue the loop or not. 01:36.600 --> 01:41.430 You know, I'm just saying that if the next variable is less than three, then keep looping. 01:42.740 --> 01:45.830 Inside, I'm going to increase the index variable by one. 01:47.040 --> 01:49.300 So that's when the airable becomes greater. 01:49.320 --> 01:49.730 That's right. 01:50.160 --> 01:51.640 The loop will be terminated. 01:53.020 --> 01:53.510 OK. 01:53.560 --> 01:58.080 Only one thing is missing right now, how to make it behave like a real loop. 01:58.810 --> 02:04.330 To do that, I'm going to use a go to statement to jump back to the loop labeled a ball like this. 02:05.290 --> 02:07.750 This statement will jump to this loop label. 02:08.700 --> 02:15.330 And then the statements right after Leupp label will be repeated again and again, so this works exactly 02:15.330 --> 02:16.670 like a real loop, right? 02:17.280 --> 02:19.890 Actually, real loops also work in this way. 02:21.420 --> 02:24.930 All right, now, let's also bring the message that the council like this. 02:26.170 --> 02:28.780 So that I can see whether it actually loops or not. 02:30.300 --> 02:34.200 Also, I'm going to print another message when the loop ends like this. 02:35.520 --> 02:37.210 All right, now the program is ready. 02:37.260 --> 02:37.890 Let's run it. 02:39.210 --> 02:44.910 As you can see, it loops three times, then it terminates from the loop, then it prints the -- message 02:45.510 --> 02:45.880 here. 02:45.900 --> 02:49.170 I've literally imitated a loop is a negative statement. 02:49.800 --> 02:51.510 This was just for demonstrating. 02:51.510 --> 02:56.640 You have the go to statement facts, but I'm not advising you to create loops like this. 02:56.640 --> 03:02.280 Of course, instead of a go to statement, I prefer using a false statement, of course, and then you 03:02.280 --> 03:05.910 need to jump, use the labels, break and continue statements. 03:07.020 --> 03:10.560 Use the Gotha statement only when it really simplifies your code. 03:10.690 --> 03:11.070 OK? 03:12.230 --> 03:16.650 Actually, it's a very simple statement, and I think it's self-explanatory. 03:17.120 --> 03:19.220 However, let me show you again visually. 03:20.160 --> 03:25.760 You just declare a label to use and go to statement to jump to that label, and that's it. 03:26.630 --> 03:29.760 However, you can't use the go to statement from anywhere. 03:30.110 --> 03:32.790 Let me show you, there are a few rules. 03:33.710 --> 03:39.740 The first rule is that code doesn't allow you to jump to a label after new wearables have been introduced. 03:40.610 --> 03:43.460 Let's take a look at an example to see what I mean by that. 03:44.090 --> 03:47.380 Airable is declared here right now. 03:47.390 --> 03:51.500 I'm going to jump to the loop label just before this declaration like this. 03:53.330 --> 03:59.870 Gore says that you can't jump after the declaration of the IRA, but think about it, what would happen 03:59.870 --> 04:03.040 if you could jump to the label without declaring the IRA? 04:03.080 --> 04:08.930 Well, in that case, the IRA wouldn't have been declared and it wouldn't be exist. 04:09.680 --> 04:16.040 Then the program would jump here and it wouldn't be able to find the IRA able if this was allowed. 04:16.070 --> 04:18.290 Think about how many bugs this will create. 04:19.380 --> 04:26.070 So go to Engo is not like the Agota statement of the historic programming languages, they allow you 04:26.070 --> 04:33.230 to jump anywhere in your statement is more restricted variation compared to those historic languages. 04:34.020 --> 04:38.760 Gore team has restricted it because Gotha can be a very dangerous statement. 04:39.960 --> 04:45.750 To learn more about the dangers of an unrestricted go to statement, please read the articles that are 04:45.750 --> 04:46.980 added to the resources. 04:47.850 --> 04:53.670 Although it's dangerous when used correctly and moderately, sometimes it may really simplify your code, 04:54.450 --> 04:56.220 but it should be the last resort. 04:56.420 --> 04:56.790 OK. 04:59.210 --> 04:59.760 Perfect. 04:59.780 --> 05:06.260 Now, you've completed all the steps, you learned a lot of knowledge in Congress, this was the last 05:06.260 --> 05:09.090 step of the part three and you made it again. 05:09.470 --> 05:10.200 That's great. 05:10.700 --> 05:13.610 Now you have to control the flow of your programs. 05:14.240 --> 05:15.050 Thank you for watching. 05:15.050 --> 05:17.390 So far, seeing the next part of my.