Welcome in this lecture, I'm going to talk about the capacity of facilities in more detail.
All right, let's get started.
This declaration creates a new slice like this one.
This is a new slice, so it doesn't have a backing away, so all its fields are zero.
So why use the land function or the function on this slice?
Both will return zero.
When I use a slice literal instead, this time God creates a new back here.
There are three elements in this last Litoral, right?
So that is why the age is this begging, Kerry has three elements as a.
So the capacity is the length of the back injury of a slice, it is not the length of a slice, remember,
a slice and its back injury are different values.
So after creating the big Kerry, Gore returns a header here, the slides refers to the first element
of its back injury.
And after the first element, there are three elements in the array.
So that is why the slicers capacity is three here.
Socialises capacity is all about the length of his leg injury and where the slide starts.
Since the age of Slice sees all the elements of its air, so its length is also three.
So why use a slice Litoral directly, the capacity and the length of the slice will be the same.
Let's slice the edges slice to create an empty slice from its.
When I do so, it's length becomes zero, but its capacity remains the same, remember, as Selassie's
capacity is all about its begging koray and where it starts, the slice doesn't have any elements,
but it's Erra has three elements, and the slice starts from the first element of the era.
That is why its capacity is still three.
I can start this slice by using the available capacity inside its Pechanga, for example, let me assign
this slice to a variable.
And now I'm going to slice the aid slice up to its maximum capacity.
I extended the slice back to its full capacity.
I can do so because there was enough capacity in the back injury, so the capacity of fossilise determines
how much you can extend it.
Remember, as soldier's expression returns a newsless value.
So the extended slice is not the original one.
It is a new slice.
By the way, I can do the same thing.
Using the cap function like this is because the function returns the maximum capacity of a slice.
So it returns three because the slices these three, let's try to extend the slice beyond its capacity.
As you can see, I cannot do that because the slices Ceppos these three, not four.
So you cannot extend the slice beyond its capacity is because there isn't enough space left in the begging
array to do so.
Anyways, let's return back and slice it differently.
So after slicing it like this, the capacity becomes too, it's because these new slice is referring
to the second element of the array and there are two more elements in the area.
And its length is two, because it sees the last two elements of its air.
Notice that the pointer is not for the eight anymore.
It is 56.
It is eight bytes.
Memory s away from the first element, so the slice cannot see the first element of its baking array
anymore.
This time, the slide starts from the third element, this means that it cannot see the previous elements
of the array for the slice.
Its error has only one element.
That is why its capacity is one now.
This time, the slice is beyond the last element, so the slices capacity is zero is because for the
slice, it doesn't contain any elements.
Interestingly, though, the slice still points to the beginning of its array.
However, you cannot use the previous elements so the pointer field isn't meaningful by itself.
That is why the slice Heather needs to store the length and the cupboards, the fields as well.
Let me assign the last slice exploration's result to the same slice variable.
No slice there again, but I cannot do so.
It's because God knows that the capacity of the slice is zero, so it doesn't allow me to extend the
slice back even though it knows where its error is located on the memory.
So value lost the original slice.
Heather, you cannot extend it back as in here.
If I hadn't overwritten the slice, I could have extended.
All right.
That's all for now in the next lecture.
I'm going to show you an example in the coding, Ed..
So you can understand the capacity concept better.
See you there by.