Valka, let me quickly summarize roadmap.
In the first step, you're going to learn about the shortage statement.
In the second step, I'm going to talk about how the scope works when a short if statement is used.
And the last step, I'm going to show you another example program about shadowing, I will show you
how one of the famous coaches in Gullberg and how to solve it.
All right, let's get started.
Welcome again in lecture.
I'm going to talk about using a simple statement with an if statement, by the way, a simple statement
is also called the short statement.
As I told you before, on a single line of code, that should be only one statement, right?
However, there is an exception to that rule.
So some statements can be used in other statements on the same line.
Short statements allow you to do that, for example, you can use an intake statement or you can short
declare variables using a short statement.
By the way, short statements are not only for the if statements, as you'll see later, that they can
also be used in other control flow statements such as speech and false statements.
So everything you learn here will also be usable within some other control flow of statements.
OK, let's get started.
It's better to use an example first.
Now I'm going to show you a very you can use a short statement if statement.
They say that you want to convert 40 to to an integer number using the way to our function like this.
You've seen it before.
It takes a scenic value and converts it to an end value.
Right.
Now let's check for the air and display the converted number like this.
So this statement will only be executed when the conversion is successful and Arabela is new, right?
So far there is nothing interesting here.
You already learned about this previously.
Now let's learn how we can do this in a much quicker and nicer way, using a simple statement, because,
as you know, Gore is all about brevity and simplicity.
Now I'm going to move the function, call into the if statement and show you.
Here I moved the function call into the if statement.
Now I can check whether there was an error or not in that very same if statement along with the to function
call.
Let me show you how it works.
This highlighted part here is a simple statement.
But if statements runs, it will first called a two hour function than the returned values from the
function will be saved into the end and the other variables as before.
Simple statements can be very useful for quickly checking the errors and then running the right inside
the if statement if everything is OK.
Now, I've highlighted this little separator talking here, it just a semicolon, it separates the simple
statement and the condition expression, the semicolon is very important or the if statement made a
simple statement, Montrachet.
Now, I've highlighted the last part is, you know, already this is the condition expression of any
statement, right, is you can also see that the condition expression can use the variables which are
declared in the simple statement here.
I'm comparing the variable that will be returned from the way to our function to nil.
So if it's nil, then I'm just printing that the conversion last successful.
Now, let me tell you something very important.
These highlighted variables here can only be used within this if statement on.
So outside of this, if statement is wearables will not be available, as I said before, a simple statement
is not only for the if statement.
So when you declare a variable using a simple statement, it will only be available to the statement
that includes that simple statement.
Another important thing to note here is that these variables will also be available to all the following
branches inside the statement, like the hours and hours of branches.
OK, in the next picture, I'm going to show you an example program so you understand it better.
See you there.