1 00:00:00,910 --> 00:00:02,480 Using the comma operator. 2 00:00:02,500 --> 00:00:05,440 The operator shall be covered later in the section. 3 00:00:06,010 --> 00:00:10,630 However, it's useful to introduce the comma operator here. 4 00:00:11,650 --> 00:00:17,160 So you can have a second set of expression separated by a comma as a single statement. 5 00:00:17,170 --> 00:00:23,210 For example, let's create an example code here to show you how this common trait works. 6 00:00:23,230 --> 00:00:25,360 Integer A equals nine. 7 00:00:25,510 --> 00:00:27,820 For example, integer equals nine. 8 00:00:28,300 --> 00:00:29,240 Integer. 9 00:00:29,260 --> 00:00:32,560 B equals four. 10 00:00:33,780 --> 00:00:34,340 Integers. 11 00:00:34,410 --> 00:00:36,350 C equals nothing. 12 00:00:36,360 --> 00:00:39,360 So it's you automatically zero. 13 00:00:40,140 --> 00:00:50,850 So let's see, equals E plus eight and com operator B plus one. 14 00:00:51,630 --> 00:00:55,650 So as you can see here, we have a slight problem here. 15 00:00:55,680 --> 00:01:03,870 So this code compiled and run with that problem and the variable C will be assigned with the value of 16 00:01:03,870 --> 00:01:05,000 17. 17 00:01:05,880 --> 00:01:11,070 Let's print it and I will show you what this is. 18 00:01:11,700 --> 00:01:13,020 See here. 19 00:01:13,020 --> 00:01:15,270 And std. 20 00:01:16,020 --> 00:01:18,570 STD and L here. 21 00:01:20,060 --> 00:01:21,860 So let's apprentice here. 22 00:01:21,860 --> 00:01:24,680 As you can see here, we got 11. 23 00:01:24,680 --> 00:01:31,570 So a plus nine, a plus nine and we will get 11. 24 00:01:31,580 --> 00:01:33,670 But where is our five? 25 00:01:33,680 --> 00:01:38,150 So as you know, four plus one equals. 26 00:01:40,230 --> 00:01:41,020 Equals five. 27 00:01:41,040 --> 00:01:42,800 So here. 28 00:01:42,990 --> 00:01:43,860 SAMILTON. 29 00:01:44,600 --> 00:01:45,290 And. 30 00:01:46,430 --> 00:01:48,350 Uh, 17 and five. 31 00:01:48,380 --> 00:01:54,530 As you can see, this 17 and five did not multiply. 32 00:01:54,530 --> 00:01:56,270 So that's because of the. 33 00:01:56,840 --> 00:01:59,420 The commerce operator is not a multiply here. 34 00:01:59,420 --> 00:02:01,790 So I will explain what this comma is. 35 00:02:01,910 --> 00:02:07,580 So the reason is that this is the reason that the comma operator. 36 00:02:08,720 --> 00:02:14,870 Separates the right side of the assignment into two expressions. 37 00:02:16,160 --> 00:02:21,800 A plus one and B plus A plus eight and B plus one. 38 00:02:21,800 --> 00:02:27,170 And it uses the value of the first expression to assign C. 39 00:02:27,800 --> 00:02:32,570 Later in this course, we will look at the operator precedence. 40 00:02:32,780 --> 00:02:43,370 However, it's worth saying here that the comma has the lowest precedence and plus has higher precedence 41 00:02:44,900 --> 00:02:47,350 than equal to sign here. 42 00:02:47,390 --> 00:02:54,650 So the statement is executed in order of the addition to the addition of the addition. 43 00:02:54,650 --> 00:03:02,600 So the assignment and then the comma operator with the result of B plus one thrown away just as earlier. 44 00:03:02,630 --> 00:03:11,660 As you can see, we just get 17 from C here so you can change the presidents using the parentheses to 45 00:03:11,660 --> 00:03:12,650 group expressions. 46 00:03:12,650 --> 00:03:15,340 For example, let's. 47 00:03:17,180 --> 00:03:21,670 And mistyped called could have been here as follows. 48 00:03:21,680 --> 00:03:26,620 Let's get into the parenthesis and see what happens here. 49 00:03:26,630 --> 00:03:29,840 As you can see here, we got the five now. 50 00:03:30,970 --> 00:03:40,170 So the result of this statement is variable C assigned to five, B plus one, and where is our 17 here? 51 00:03:40,180 --> 00:03:46,230 So the reason is that with the common operator expression are executed from the left to right. 52 00:03:46,240 --> 00:03:50,770 So the value of the group of expression is the most one. 53 00:03:50,770 --> 00:03:57,220 So there are some cases, for example in the initialization or loop expression for a for loop where 54 00:03:57,220 --> 00:04:00,130 you will find the common operator useful. 55 00:04:00,130 --> 00:04:08,650 But as you can see here, even used intentionally, the common operator produced hard to read code. 56 00:04:09,400 --> 00:04:11,530 So now actually. 57 00:04:12,810 --> 00:04:14,700 Let's end our. 58 00:04:17,820 --> 00:04:25,710 Lecture now, and in the next lecture you will learn about your types and variables.