WEBVTT 00:01.170 --> 00:07.740 Malcolm, in this lecture, I'm going to show you how to compare a race, you'll learn why the type 00:07.740 --> 00:11.320 of UNRRA is very important when you are comparing race. 00:11.850 --> 00:12.850 So let's get started. 00:14.750 --> 00:21.620 Let's say you've been buying books from Hipsters Love Bookstore for the last years, so now you want 00:21.620 --> 00:28.460 to put them in your bookcase in this bookcase, you can store only nine books on each shelf. 00:28.490 --> 00:28.910 OK. 00:29.960 --> 00:32.960 And some of your Chelse store, your other books. 00:33.990 --> 00:42.330 So the first shove can store six more books and the second one is completely empty so that it can store 00:42.330 --> 00:50.640 nine books and the last shelf can store three more books, you have decided to count how many books 00:50.640 --> 00:53.140 that you can store on this bookcase. 00:53.160 --> 00:53.550 OK. 00:54.460 --> 00:57.370 To do that, you can use that area such as this one. 00:59.050 --> 01:03.790 So each element of this array represents the remaining shelf capacity. 01:03.870 --> 01:08.020 OK, here, this area literally creates this array. 01:09.080 --> 01:16.280 I'm going to explain the rest of the lecture using this bookcase analogy here, I'm talking about a 01:16.280 --> 01:17.030 bookcase. 01:17.310 --> 01:24.300 However, in real life, this can be a data buffer, records in a database and so on. 01:25.130 --> 01:29.180 So what you're going to learn here is also applicable to the real world. 01:29.330 --> 01:36.500 As always, the important thing is the mind set that you are going to get by learning the things in 01:36.500 --> 01:38.180 simple ways like this. 01:38.360 --> 01:45.800 You will gain more intuition and this will lead to more creativity while you are working on real world 01:45.800 --> 01:46.430 problems. 01:46.460 --> 01:49.250 OK, so without further ado, let's get started. 01:50.480 --> 01:57.110 Now, let's say you got more books and they don't fit into your bookcase, so you got another bookcase 01:57.110 --> 01:58.710 with red color like this one. 01:59.000 --> 02:02.980 Now, you have distributed the books equally among your bookcases. 02:03.770 --> 02:09.770 So now you want to know whether all the shelves on your bookcases contain the same number of books or 02:09.770 --> 02:10.120 not. 02:10.520 --> 02:13.360 To do that, you need to compare these areas. 02:13.430 --> 02:13.820 Right. 02:14.000 --> 02:17.220 Let's first talk about the rules when comparing eras. 02:17.870 --> 02:24.560 So the first rule is that the types of errors should be the same, or in other words, they are types 02:24.560 --> 02:26.140 should be identical. 02:26.180 --> 02:30.410 Here I can compare the errors because they have the same type. 02:30.740 --> 02:33.380 Their type is three entra. 02:34.220 --> 02:39.620 I mean, three here, as you know, is their land and it is their elemental. 02:41.060 --> 02:48.410 By the way, you can only compare an error if its element type is also comparable, actually almost 02:48.410 --> 02:51.550 all the types are comparable, but some are not. 02:52.160 --> 02:57.410 For example, function values, slices and maps are not comparable. 02:57.950 --> 02:59.690 You learn about them later. 02:59.750 --> 03:04.500 Now, where is the second rule is that all the elements should be equal. 03:05.180 --> 03:08.030 Let's check out the elements of the first array at left. 03:08.570 --> 03:10.700 There are six nine three. 03:10.730 --> 03:11.150 Right. 03:12.000 --> 03:15.820 And now let's check out the elements of the secondary to right. 03:16.460 --> 03:19.430 There are six, nine and three again. 03:19.760 --> 03:22.340 So they both contain the same elements. 03:22.340 --> 03:22.780 Right. 03:23.120 --> 03:25.740 So this means they are equal errors. 03:26.390 --> 03:29.060 Vango compares arrays for equality. 03:29.510 --> 03:33.950 It checks each one of the elements of both of the errors one by one. 03:34.070 --> 03:36.350 Here are assigned to erase two variables. 03:36.470 --> 03:39.380 To show you how we go compares the arrays. 03:40.130 --> 03:46.280 So the blue variable stores, the first array value at the left and the right variable stores, the 03:46.280 --> 03:48.440 second array value at the right. 03:49.190 --> 03:52.970 Now I'm going to show you how God compares these two arrays. 03:53.480 --> 03:54.440 It is like this. 03:55.110 --> 04:00.290 It compares the first element of the blue error to the first element of the red array. 04:01.070 --> 04:02.840 Six equals to six. 04:03.200 --> 04:07.700 So it returns true and Gore continues checking for the other elements. 04:08.480 --> 04:11.690 Then it compares the second elements of the error. 04:12.470 --> 04:13.890 Nine equals two nine. 04:13.910 --> 04:16.130 So this comparison also returns. 04:16.130 --> 04:16.420 True. 04:16.880 --> 04:20.860 And lastly, it compares the last elements of the errors. 04:21.350 --> 04:24.590 Three equals to three is also returns. 04:24.590 --> 04:24.920 True. 04:25.280 --> 04:28.580 So God decides that both errors are equal. 04:30.330 --> 04:37.590 Now, I reversed the elements of the secondary, although they contain the same elements, these areas 04:37.590 --> 04:41.400 are not equal because their elements are not in the same order. 04:41.640 --> 04:46.920 However, they are still comparable because there types are the same three int. 04:47.960 --> 04:52.900 Let's look at the elements of the area at the left it is six, nine and three. 04:53.300 --> 04:54.620 Now let's look at the area. 04:54.620 --> 04:57.770 At the right it is three, nine and six. 04:58.430 --> 05:01.460 They have the same elements, but in a different order. 05:01.640 --> 05:02.720 So they are not equal. 05:04.600 --> 05:05.840 Here is a question for you. 05:06.250 --> 05:06.970 What do you think? 05:07.330 --> 05:09.220 Are these areas comparable? 05:10.490 --> 05:12.890 Police post the video now and think about it. 05:17.960 --> 05:19.130 All right, let's take a look. 05:20.200 --> 05:28.210 Here, the blue arrows type is three isn't right, and the red arrows type is to int, so there types 05:28.210 --> 05:30.380 are entirely different. 05:31.060 --> 05:36.190 This means these are not comparable since there types are different. 05:36.430 --> 05:36.860 OK. 05:38.100 --> 05:40.950 OK, let's take a look at an example in the coding, Ed. 05:43.660 --> 05:50.080 Let's declare two areas which represent the bookcases I'm going to declare the blue book is first. 05:51.640 --> 05:52.660 And the Red Bull case. 05:53.430 --> 05:56.560 OK, now I'm going to print the Blue Book is. 05:59.380 --> 06:00.700 And the Red Bull case. 06:01.970 --> 06:02.570 Limerence. 06:03.930 --> 06:04.410 All right. 06:05.390 --> 06:11.030 Now, let's compare the areas like this, I'm going to type are they equal and I'm going to compare 06:11.030 --> 06:13.700 the areas using an equal operator like this. 06:15.220 --> 06:16.720 As you can see, they are equal. 06:17.230 --> 06:20.590 OK, now I'm going to define the blue areas length with the ellipses. 06:21.870 --> 06:26.580 As you can see, they are still equal because blue arrows land is still three. 06:27.360 --> 06:29.000 Let me change this back to three. 06:29.470 --> 06:31.620 OK, now let me change this secondary. 06:33.610 --> 06:39.640 As you can see now, they are not equal because the order of their elements is different now. 06:40.330 --> 06:42.310 OK, let's take this back now. 06:42.310 --> 06:44.650 I'm going to remove the last element of the blue. 06:47.100 --> 06:53.390 Now, they are not equal because the last element of the blue area is zero, and now Gore has assigned 06:53.390 --> 06:54.570 to zero value to it. 06:55.350 --> 06:57.760 OK, let's put the last element back. 06:58.320 --> 07:00.430 Now I'm going to change the length of the red. 07:01.410 --> 07:08.440 Now, if there is an error, Gore says that these two arrays are not equal because are types are different. 07:08.460 --> 07:13.200 Remember, the length of an error is an inseparable part of its type. 07:13.530 --> 07:18.270 Again, the length of an array is an inseparable part of its type. 07:18.480 --> 07:19.230 This is important. 07:19.980 --> 07:22.110 OK, let me take this back again, OK? 07:22.650 --> 07:25.850 And lastly, let's change the elements of the first array. 07:25.890 --> 07:28.350 For example, there is the same error. 07:28.350 --> 07:32.250 Again, it says the types of errors are different. 07:32.760 --> 07:38.440 Remember, the element type of an error is also an inseparable part of its type. 07:38.850 --> 07:43.140 So these arrests are not comparable because they're types are different. 07:44.160 --> 07:48.070 All right, that's all for now, seeing the next picture, our.