Welcome in this lecture, I'm going to show you how we can use the short, sweet statement.
It's very similar to the short if statement, actually.
OK, let's take it out now.
Remember this?
It just checks whether the airable is positive or negative or zero, as you can see, these airable
here is declared out of the switch statements block, right.
But actually, you could declare it using a simple statement right inside the switch statement.
Like a short if statement, a switch statement can also use a simple statement.
Let me show you.
As you can see, I just moved the short verbal declaration just before the Salvages condition.
Now, you may wonder where is the soldier's condition?
Then use a simple statement, you also need to use a semicolon to separate the simple statement and
the condition like this or go won't be able to recognize that whether this is a simple statement or
is just a switch is condition.
Now, this time, the Savages condition is true, since I want to find out a condition which yields
a true value.
Let's take a look at it in detail now.
As I said, this highlighted part is a simple statement, then go get across a switch statement and
if it has a simple statement, as in here, it would run it first and only once.
Like a short statement, the short, sweet statement also uses a simple statement, the same rules also
apply like scoping.
I suggest you to watch the short lecture again, to learn more about the simple statements if you don't
remember them.
Here are some examples, simple statements.
These all are simple statements.
You can also use expressions.
For example, you can call a function.
All right, now let's continue.
This is a separator, as I said, it's just a single semicolon token, it just separates the simple
statement and the switches condition explanation.
OK, let's continue.
You know, this one, it is the switch conditioned expression now is true, but as you learned before,
you don't need to type it if it's true.
I'm just put it here to show you the whole statement with a separator, let's remove it now.
All right, better actually, as the condition expression true is still there, it's just hidden.
So that's why you still need to keep the semicolon as a separator there.
All right, that's all.
Congrats.
Now we know how to use the short switch statements in the next lecture.
I'm going to show you an example program.
See you in the next lecture.
Well, by.