Malcolm, in this lecture, I'm going to show you how to compare a race, you'll learn why the type
of UNRRA is very important when you are comparing race.
So let's get started.
Let's say you've been buying books from Hipsters Love Bookstore for the last years, so now you want
to put them in your bookcase in this bookcase, you can store only nine books on each shelf.
OK.
And some of your Chelse store, your other books.
So the first shove can store six more books and the second one is completely empty so that it can store
nine books and the last shelf can store three more books, you have decided to count how many books
that you can store on this bookcase.
OK.
To do that, you can use that area such as this one.
So each element of this array represents the remaining shelf capacity.
OK, here, this area literally creates this array.
I'm going to explain the rest of the lecture using this bookcase analogy here, I'm talking about a
bookcase.
However, in real life, this can be a data buffer, records in a database and so on.
So what you're going to learn here is also applicable to the real world.
As always, the important thing is the mind set that you are going to get by learning the things in
simple ways like this.
You will gain more intuition and this will lead to more creativity while you are working on real world
problems.
OK, so without further ado, let's get started.
Now, let's say you got more books and they don't fit into your bookcase, so you got another bookcase
with red color like this one.
Now, you have distributed the books equally among your bookcases.
So now you want to know whether all the shelves on your bookcases contain the same number of books or
not.
To do that, you need to compare these areas.
Right.
Let's first talk about the rules when comparing eras.
So the first rule is that the types of errors should be the same, or in other words, they are types
should be identical.
Here I can compare the errors because they have the same type.
Their type is three entra.
I mean, three here, as you know, is their land and it is their elemental.
By the way, you can only compare an error if its element type is also comparable, actually almost
all the types are comparable, but some are not.
For example, function values, slices and maps are not comparable.
You learn about them later.
Now, where is the second rule is that all the elements should be equal.
Let's check out the elements of the first array at left.
There are six nine three.
Right.
And now let's check out the elements of the secondary to right.
There are six, nine and three again.
So they both contain the same elements.
Right.
So this means they are equal errors.
Vango compares arrays for equality.
It checks each one of the elements of both of the errors one by one.
Here are assigned to erase two variables.
To show you how we go compares the arrays.
So the blue variable stores, the first array value at the left and the right variable stores, the
second array value at the right.
Now I'm going to show you how God compares these two arrays.
It is like this.
It compares the first element of the blue error to the first element of the red array.
Six equals to six.
So it returns true and Gore continues checking for the other elements.
Then it compares the second elements of the error.
Nine equals two nine.
So this comparison also returns.
True.
And lastly, it compares the last elements of the errors.
Three equals to three is also returns.
True.
So God decides that both errors are equal.
Now, I reversed the elements of the secondary, although they contain the same elements, these areas
are not equal because their elements are not in the same order.
However, they are still comparable because there types are the same three int.
Let's look at the elements of the area at the left it is six, nine and three.
Now let's look at the area.
At the right it is three, nine and six.
They have the same elements, but in a different order.
So they are not equal.
Here is a question for you.
What do you think?
Are these areas comparable?
Police post the video now and think about it.
All right, let's take a look.
Here, the blue arrows type is three isn't right, and the red arrows type is to int, so there types
are entirely different.
This means these are not comparable since there types are different.
OK.
OK, let's take a look at an example in the coding, Ed.
Let's declare two areas which represent the bookcases I'm going to declare the blue book is first.
And the Red Bull case.
OK, now I'm going to print the Blue Book is.
And the Red Bull case.
Limerence.
All right.
Now, let's compare the areas like this, I'm going to type are they equal and I'm going to compare
the areas using an equal operator like this.
As you can see, they are equal.
OK, now I'm going to define the blue areas length with the ellipses.
As you can see, they are still equal because blue arrows land is still three.
Let me change this back to three.
OK, now let me change this secondary.
As you can see now, they are not equal because the order of their elements is different now.
OK, let's take this back now.
I'm going to remove the last element of the blue.
Now, they are not equal because the last element of the blue area is zero, and now Gore has assigned
to zero value to it.
OK, let's put the last element back.
Now I'm going to change the length of the red.
Now, if there is an error, Gore says that these two arrays are not equal because are types are different.
Remember, the length of an error is an inseparable part of its type.
Again, the length of an array is an inseparable part of its type.
This is important.
OK, let me take this back again, OK?
And lastly, let's change the elements of the first array.
For example, there is the same error.
Again, it says the types of errors are different.
Remember, the element type of an error is also an inseparable part of its type.
So these arrests are not comparable because they're types are different.
All right, that's all for now, seeing the next picture, our.