Welcome.
Until now, you have learned a lot of things about the gold type system.
Yet there are still many things that we need to talk about, so now here is the next thing that you
need to learn.
The unnamed types.
By the way, if you want to understand this lecture correctly, then you should watch the previous call
type system lectures.
If you didn't watch them yet, please do so now.
All right.
Let's get started.
Let's first learn what an unnamed type is, here's an error with three elements.
The interesting thing here is that this is an unnamed type.
This means a type definition hasn't defined it, so it doesn't have a name.
Here is a quick question for you.
What is the underlying type of this area?
Please post a video and think about it.
All right, I'm back.
This area is on the line type is, well, itself, so it's underlying type is this three Endara type,
but why?
Remember, an underlying type has a real structure, so here this array literally defines its own size
and its own representativity.
Right.
I mean, it defines a unique memory without which is consisting of three elements.
It has literally defined the new modern unnamed type on the fly.
And lastly, this is not only true for errors, it's also true for all the other composite types.
We learn about them afterwards.
Our.
Now, let's take a look at a name type, this type definition creates a new array type with a new name.
So the name of this type is Bookcase.
Here is another question for you.
What is the underlying type of the bookcase type?
Police post video and think about it.
All right, it's on the line, time is three ain't right, so this bookcase type gets its type from
this tree int unintegrated.
OK, now let's create an error literal using this new type.
This is an early trial, but I declared it with the book type, which is a name type.
So this arrays type is not just treatment, its type is bookcase.
Now, let's create another era with an unnamed three in type like this, can we compare these areas?
What do you think?
Please post a video and think about it again.
Yes, we can do wonder why.
It's because their underlying type is the same.
So this means a value with an unnamed type can be compared to a value with a name type as long as they
have identical underlying types.
The opposite of this also true, their underlying type is identical because they have the same structure.
They both contain three values.
So you can't directly compare them.
You don't need to convert them by yourself.
It's because implicitly converts them for you.
Let me show you one more example.
Now I'm going to declare another type cabinet and now I'm going to create a new array using this cabinet
type.
Here is a question for you.
Can we compare these array values?
What do you think?
Please past video and think about it again.
Nope, we can't compare them, their underlying type is the same, right?
So why we can't compare them?
It's because their top names are different.
Remember, a name type is always a different type than any other type.
OK, but there is still a way to compare them.
Let's take a look.
So guess how we can compare them?
Remember, their underlying type is the same, so we can convert a bookcase value to our cabinets value
or a cabinet value to a book is value in addition to that.
Now, we can also compare them is because those values have the same types.
Now they both are bookcase values.
Now, by the way, you can only convert them if they're underlying types are identical.
I'm not going to talk about this again because I have already talked about this in the go type system
section before.
Now, let's take a look at what you learned so far in decoding Ed.
Remember the previous example where I've been comparing two bookcases with different colors, blue and
red.
So now I'm going to declare two areas using unnamed types like this.
First, I'm going to declare this blue array variable with five elements like this.
Another one.
OK, let's compare them.
First, I'm going to type a message like this.
Are they equal?
Then I'm going to compare these variables if they are equal.
I'm going to print this.
Otherwise, I'm going to print this.
All right, run, as you can see, they are equal.
Let me also print them with their types like this.
Bluebox.
And the red.
OK, let's run it.
As you can see, they both are the same unnamed five injuries.
All right, now I'm going to declare a new type.
The first one is this bookcase type.
So the bookcase is on the line.
Time is five Eynesbury.
Now, take a look at this blue variable here.
I'm going to change its type to the bookcase type.
That's right, it works.
There are still comparable and they are equal because there underlying type is identical.
Their underlying type is five in there.
Notice also that none of the blue erase type is a name type.
When I printed it gets printed as mean that bookcase instead of just five.
It is because its type is bookcase, which is a name type, not an unnamed type like five entero.
OK, now I'm also going to declare and their name to the cabinet.
As you can see, these two types have the same underlying types, right?
Let's try to compare them.
Now, I'm going to change this unnamed area literal to the cabinet type like this.
Check out the comparison blow go compiler has called an error.
Let's check it out.
It says the bookcase and the cabinet have different types.
So there is a type mismatch here.
This happens because a name type is always a different type than any other type.
OK, let's fix it by converting one of them.
Now I'm going to convert this blue array to the cabinet type like this.
As you can see now, it works.
Let's run it as a look, it says they are equal.
Cool again.
Also, notice the type names here, the blue iris type is bookcase, whereas the red iris type is cabinet.
They are different types.
They have different names.
OK.
However, if I convert one of them, let's say this red area to the bookcase type.
Let's see what it would look like.
Now, it seems like the rhetoric type has changed on the fly, now it's a bookcase, the cabinet, right?
So whenever you convert a value, it's time to change it on the fly.
This is also true for the other composite types.
I told you that to convert them, they're Underland types should be identical.
Right.
So now I'm going to change these cabinet types on the line type to a 10 element interreg like this.
Now, Gore has called an Arab.
Let's check it out.
It says that it cannot convert the value of the bookcase type to the cabinet, that it's because the
underlying tab is different now.
All right.
Let me take this back.
And Lussier, let me show you one more thing.
Now I'm going to declare a new integer type like this, then I'm going to change the element type of
the cabinet type like this.
As you can see, there are errors.
Now let's check it out, go cannot convert blue here to the cabinet type.
But why?
It's because now they're on the line, types are different, the cabinet type is on the line, type
is not.
Five isn't anymore, it is five.
Integer is the name type but the underlying type of the integer and the int is the same, right?
It is the same in type.
So why they have different underlying types now.
Remember, an unnamed type's on the line is itself here, five integer is an unnamed type, so it's
underlying tab is itself, which is five integer.
That's why five integer and five are different types there on the line types are different.
Let me give you one more example.
For example, here, this comparison is incorrect, it's because they have different underlying types,
one is five integer, the other one is five int.
But I can do this.
This is because the cabinets on the laptop is five integer, remember, an unnamed type and a name type
can be compared if they have identical underlying ties.
So that's why I can compare them here.
All right, that's all for now, as always, in the upcoming sections, you will understand this better.
If you didn't understand it yet, please open this example and work on it.
OK, do your own experimentations.
By the way, the knowledge you have gained from this lecture will be very valuable in the upcoming lectures
as well as in your real world go programs.
And this is also important because it allows you to understand the gold type system in full detail.
Thank you for watching so far.
See in the next lecture.