And this lecture.
Let's take a look at what a clone is.
So if we want to actually take the value of a variable without taking ownership, we can perform a clone
which performs a deep copy.
And what this is going to do is it's going to take the values from the variable we are referencing and
copy them into a new variable.
Doing a clone may be expensive, but let's check out how it works.
So I'm going to take all this code.
I'm a copy it and then I'm going to comment it out up here and we're just going to print it down here.
So it's going to we have the same thing so far, but now we want to do a clone on X and then we want
to clone on Y.
So now if we do this and you know what, let's actually go ahead and let's let's print out all of them
real quick just to make sure that everything works.
So we created our our vector with just the Tyler string in it.
We told Y to be a clone of X and we told Z to be a clone of y, which was a clone of x.
So now when we run this.
We see Tyler, Tyler, Tyler.
So what this means is, is we completed a deep copy of X and we were able to assign the string of Tyler
to Y and Z.
So now, as you can imagine, this can be a very expensive operation.
Imagine if you have a vector with hundreds of thousands of values in it and then you try to clone it.
It's going to clone every single value inside that vector into the new variable.
So as you can imagine, it is an expensive operation to do.
But.
Let's look at what a copy is in the next lecture.