Using the comma operator.
The operator shall be covered later in the section.
However, it's useful to introduce the comma operator here.
So you can have a second set of expression separated by a comma as a single statement.
For example, let's create an example code here to show you how this common trait works.
Integer A equals nine.
For example, integer equals nine.
Integer.
B equals four.
Integers.
C equals nothing.
So it's you automatically zero.
So let's see, equals E plus eight and com operator B plus one.
So as you can see here, we have a slight problem here.
So this code compiled and run with that problem and the variable C will be assigned with the value of
17.
Let's print it and I will show you what this is.
See here.
And std.
STD and L here.
So let's apprentice here.
As you can see here, we got 11.
So a plus nine, a plus nine and we will get 11.
But where is our five?
So as you know, four plus one equals.
Equals five.
So here.
SAMILTON.
And.
Uh, 17 and five.
As you can see, this 17 and five did not multiply.
So that's because of the.
The commerce operator is not a multiply here.
So I will explain what this comma is.
So the reason is that this is the reason that the comma operator.
Separates the right side of the assignment into two expressions.
A plus one and B plus A plus eight and B plus one.
And it uses the value of the first expression to assign C.
Later in this course, we will look at the operator precedence.
However, it's worth saying here that the comma has the lowest precedence and plus has higher precedence
than equal to sign here.
So the statement is executed in order of the addition to the addition of the addition.
So the assignment and then the comma operator with the result of B plus one thrown away just as earlier.
As you can see, we just get 17 from C here so you can change the presidents using the parentheses to
group expressions.
For example, let's.
And mistyped called could have been here as follows.
Let's get into the parenthesis and see what happens here.
As you can see here, we got the five now.
So the result of this statement is variable C assigned to five, B plus one, and where is our 17 here?
So the reason is that with the common operator expression are executed from the left to right.
So the value of the group of expression is the most one.
So there are some cases, for example in the initialization or loop expression for a for loop where
you will find the common operator useful.
But as you can see here, even used intentionally, the common operator produced hard to read code.
So now actually.
Let's end our.
Lecture now, and in the next lecture you will learn about your types and variables.