WEBVTT 00:00.590 --> 00:03.050 Valka, let me quickly summarize roadmap. 00:04.050 --> 00:07.110 In the first step, you're going to learn about the shortage statement. 00:08.010 --> 00:13.140 In the second step, I'm going to talk about how the scope works when a short if statement is used. 00:14.230 --> 00:19.240 And the last step, I'm going to show you another example program about shadowing, I will show you 00:19.240 --> 00:22.510 how one of the famous coaches in Gullberg and how to solve it. 00:23.290 --> 00:24.430 All right, let's get started. 00:27.420 --> 00:29.040 Welcome again in lecture. 00:29.070 --> 00:34.770 I'm going to talk about using a simple statement with an if statement, by the way, a simple statement 00:34.770 --> 00:36.720 is also called the short statement. 00:37.550 --> 00:41.990 As I told you before, on a single line of code, that should be only one statement, right? 00:42.480 --> 00:44.880 However, there is an exception to that rule. 00:45.080 --> 00:48.820 So some statements can be used in other statements on the same line. 00:49.760 --> 00:55.490 Short statements allow you to do that, for example, you can use an intake statement or you can short 00:55.490 --> 00:57.590 declare variables using a short statement. 00:57.950 --> 01:02.930 By the way, short statements are not only for the if statements, as you'll see later, that they can 01:02.930 --> 01:07.450 also be used in other control flow statements such as speech and false statements. 01:07.820 --> 01:12.740 So everything you learn here will also be usable within some other control flow of statements. 01:13.370 --> 01:14.450 OK, let's get started. 01:16.420 --> 01:18.400 It's better to use an example first. 01:18.640 --> 01:22.330 Now I'm going to show you a very you can use a short statement if statement. 01:23.260 --> 01:27.940 They say that you want to convert 40 to to an integer number using the way to our function like this. 01:29.110 --> 01:30.080 You've seen it before. 01:30.140 --> 01:33.480 It takes a scenic value and converts it to an end value. 01:33.630 --> 01:33.880 Right. 01:35.030 --> 01:38.690 Now let's check for the air and display the converted number like this. 01:41.380 --> 01:47.790 So this statement will only be executed when the conversion is successful and Arabela is new, right? 01:48.520 --> 01:50.610 So far there is nothing interesting here. 01:50.650 --> 01:53.050 You already learned about this previously. 01:53.260 --> 01:58.960 Now let's learn how we can do this in a much quicker and nicer way, using a simple statement, because, 01:58.960 --> 02:02.170 as you know, Gore is all about brevity and simplicity. 02:03.150 --> 02:06.960 Now I'm going to move the function, call into the if statement and show you. 02:11.850 --> 02:14.720 Here I moved the function call into the if statement. 02:15.110 --> 02:21.060 Now I can check whether there was an error or not in that very same if statement along with the to function 02:21.090 --> 02:21.300 call. 02:21.910 --> 02:23.340 Let me show you how it works. 02:26.070 --> 02:28.500 This highlighted part here is a simple statement. 02:29.580 --> 02:35.730 But if statements runs, it will first called a two hour function than the returned values from the 02:35.730 --> 02:39.600 function will be saved into the end and the other variables as before. 02:40.700 --> 02:46.260 Simple statements can be very useful for quickly checking the errors and then running the right inside 02:46.260 --> 02:48.080 the if statement if everything is OK. 02:49.740 --> 02:56.250 Now, I've highlighted this little separator talking here, it just a semicolon, it separates the simple 02:56.250 --> 03:02.580 statement and the condition expression, the semicolon is very important or the if statement made a 03:02.580 --> 03:04.520 simple statement, Montrachet. 03:06.130 --> 03:11.320 Now, I've highlighted the last part is, you know, already this is the condition expression of any 03:11.320 --> 03:17.350 statement, right, is you can also see that the condition expression can use the variables which are 03:17.350 --> 03:20.290 declared in the simple statement here. 03:20.290 --> 03:24.700 I'm comparing the variable that will be returned from the way to our function to nil. 03:24.850 --> 03:28.990 So if it's nil, then I'm just printing that the conversion last successful. 03:30.930 --> 03:33.080 Now, let me tell you something very important. 03:34.890 --> 03:39.410 These highlighted variables here can only be used within this if statement on. 03:40.340 --> 03:47.450 So outside of this, if statement is wearables will not be available, as I said before, a simple statement 03:47.450 --> 03:49.450 is not only for the if statement. 03:50.150 --> 03:55.520 So when you declare a variable using a simple statement, it will only be available to the statement 03:55.520 --> 03:57.890 that includes that simple statement. 03:59.170 --> 04:04.780 Another important thing to note here is that these variables will also be available to all the following 04:04.780 --> 04:08.620 branches inside the statement, like the hours and hours of branches. 04:09.500 --> 04:14.380 OK, in the next picture, I'm going to show you an example program so you understand it better. 04:14.780 --> 04:15.430 See you there.