1 00:00:06,060 --> 00:00:06,990 And this lecture. 2 00:00:06,990 --> 00:00:10,170 Let's take a look at what a clone is. 3 00:00:10,680 --> 00:00:17,970 So if we want to actually take the value of a variable without taking ownership, we can perform a clone 4 00:00:17,970 --> 00:00:20,190 which performs a deep copy. 5 00:00:20,430 --> 00:00:25,770 And what this is going to do is it's going to take the values from the variable we are referencing and 6 00:00:25,770 --> 00:00:28,800 copy them into a new variable. 7 00:00:29,550 --> 00:00:34,790 Doing a clone may be expensive, but let's check out how it works. 8 00:00:34,800 --> 00:00:37,260 So I'm going to take all this code. 9 00:00:37,260 --> 00:00:41,970 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. 10 00:00:41,970 --> 00:00:49,380 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 11 00:00:49,380 --> 00:00:52,530 to clone on Y. 12 00:00:53,670 --> 00:00:59,730 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 13 00:00:59,730 --> 00:01:03,600 real quick just to make sure that everything works. 14 00:01:04,110 --> 00:01:10,560 So we created our our vector with just the Tyler string in it. 15 00:01:10,800 --> 00:01:17,370 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. 16 00:01:17,370 --> 00:01:19,110 So now when we run this. 17 00:01:22,130 --> 00:01:24,350 We see Tyler, Tyler, Tyler. 18 00:01:24,650 --> 00:01:31,130 So what this means is, is we completed a deep copy of X and we were able to assign the string of Tyler 19 00:01:31,130 --> 00:01:32,120 to Y and Z. 20 00:01:33,150 --> 00:01:37,710 So now, as you can imagine, this can be a very expensive operation. 21 00:01:37,740 --> 00:01:45,360 Imagine if you have a vector with hundreds of thousands of values in it and then you try to clone it. 22 00:01:46,020 --> 00:01:51,120 It's going to clone every single value inside that vector into the new variable. 23 00:01:51,300 --> 00:01:57,060 So as you can imagine, it is an expensive operation to do. 24 00:01:57,870 --> 00:01:58,620 But. 25 00:01:59,500 --> 00:02:03,220 Let's look at what a copy is in the next lecture.