WEBVTT 00:01.730 --> 00:08.450 Welcome back, hipsters love bookstore owner told me that they want to store and display the winter 00:08.450 --> 00:13.440 and the summer books separately, so I need to think about how to do that. 00:14.090 --> 00:16.060 Well, the solution is easy. 00:16.580 --> 00:19.760 I can simply use different areas for different seasons. 00:19.760 --> 00:20.090 Right. 00:20.600 --> 00:21.260 Let me show you. 00:22.200 --> 00:26.070 Now I'm going to declare a new era for the winter books like this. 00:27.050 --> 00:32.660 I have a winter constant already, which tells me about the number of books that the bookstore is going 00:32.660 --> 00:34.760 to publish in this winter season. 00:34.790 --> 00:40.850 OK, so here I'm going to use it and I'm going to set its element type to strength. 00:41.970 --> 00:48.540 Remember, winter Constance value is one, so this area's length will also be one. 00:48.960 --> 00:54.590 Now I'm going to assign the books first element to this W books array's first element. 00:54.780 --> 00:58.920 OK, W Books means winter books, as you guessed, by the way. 00:59.160 --> 01:03.930 So first I'm going to get the first elements from the books, then I'm going to assign it. 01:03.960 --> 01:06.330 The books are first elements like this. 01:07.410 --> 01:08.430 Let me put into this a. 01:11.090 --> 01:12.250 Let's see how it looks. 01:13.640 --> 01:19.370 It looks pretty now, the winter era has a copy of the first element of the books era, right? 01:20.360 --> 01:23.400 They might also store the summer books in a new way. 01:24.230 --> 01:25.990 I have the summer constant as well. 01:26.300 --> 01:30.290 So now I'm going to use it to declare the land of this era like this. 01:31.940 --> 01:32.440 OK. 01:33.290 --> 01:40.130 Now, let's copy this summer books into this new era, the books erase the last three element stores, 01:40.130 --> 01:41.110 the summer books. 01:41.450 --> 01:45.410 So I'm going to copy the second book to bookstores, first element. 01:45.740 --> 01:49.490 And let's also copy the third book to e-books. 01:49.490 --> 01:50.990 The second element, OK? 01:51.170 --> 01:51.950 And the last one. 01:53.820 --> 01:56.070 All right, let me bring to Desa. 01:58.530 --> 02:03.150 Now, the summer book are contains the last three elements of the book, Sarah, right. 02:04.120 --> 02:10.600 Actually, there is a simpler way I can use a loop here, so let me comment on these assignments first, 02:11.230 --> 02:12.660 then I'm going to create a follow. 02:15.240 --> 02:20.820 This land function returns three because the length of the spokes area is three. 02:21.130 --> 02:22.530 OK, all right. 02:22.680 --> 02:26.370 Now I'm going to get an element of the book right at this index. 02:26.970 --> 02:32.550 OK, and now I'm going to copy a book from the book's array at this index plus one. 02:33.700 --> 02:37.360 Remember, the summer books are the last three books in the books. 02:38.020 --> 02:38.400 Right. 02:39.040 --> 02:41.400 That's why I have typed plus one here. 02:41.830 --> 02:44.800 So it starts copying from the second element of the book. 02:45.310 --> 02:45.730 OK. 02:46.660 --> 02:47.970 OK, let's see what it does. 02:49.710 --> 02:55.850 As you can see, the loop has copied the last three elements of the books array into the books Erin. 02:55.920 --> 02:57.350 All right, cool. 02:58.180 --> 03:02.480 Actually, there is a much simpler way I can use a full range loop. 03:02.500 --> 03:03.210 Let's do that. 03:03.970 --> 03:07.600 First of all, let me delete the rest of this line starting from here. 03:08.320 --> 03:10.860 And instead I'm going to use a range clause here. 03:11.020 --> 03:11.740 It's simpler. 03:12.340 --> 03:12.730 All right. 03:12.940 --> 03:13.480 That's it. 03:13.630 --> 03:14.550 Let's take it out now. 03:15.540 --> 03:18.500 As you can see, it brings the same output, right? 03:19.740 --> 03:26.790 Although the results are the same, the underlying mechanics are very different than your range over 03:26.790 --> 03:29.550 an area like this, it gets copied. 03:30.060 --> 03:30.720 Let me show you. 03:32.140 --> 03:38.560 Let me duplicate disarranged loop here now, instead of getting the indexers, I'm going to change this 03:38.800 --> 03:43.000 and I'm only going to get the values from the books I write like this. 03:43.970 --> 03:48.920 Let me also comment about this assignment and this printf calls first. 03:49.870 --> 03:55.150 Let me first show you we variable here contains the elements of the book Boxer. 03:56.190 --> 03:57.600 All right, that's right. 03:58.250 --> 04:03.160 As you can see, it brings the elements of the book sorry, so far so good. 04:03.900 --> 04:10.440 Now I'm going to delete this printer and I'm going to change the value by adding that new value LACHSA. 04:11.220 --> 04:15.510 I'm also going to uncommented this printers so you can see what the arrays contain. 04:15.880 --> 04:17.790 OK, all right, let's run. 04:17.790 --> 04:18.000 It's. 04:18.910 --> 04:21.670 As you can see, summer books are didn't change. 04:22.290 --> 04:27.850 This is because this is a copy of the original element of the S books era. 04:28.410 --> 04:34.740 So if you want to update the original error element, you can do so by directly accessing the element, 04:34.740 --> 04:37.860 using an index expression as in the above loop. 04:37.920 --> 04:45.560 OK, by the way, this is one of the gotchas that many beginner gophers fall into in the upcoming sections. 04:45.570 --> 04:48.690 I'll talk about the underlying mechanics of this mulberries. 04:49.500 --> 04:50.070 All right. 04:50.250 --> 04:53.670 After this brief side note, let me take all this back. 04:55.890 --> 05:01.560 Hipsters love bookstores owners also told me that they want to display the published books. 05:02.680 --> 05:06.340 To do that, we need to keep track of the published books, right? 05:07.130 --> 05:10.810 For example, I can create a Boolarra like this one to track them. 05:12.500 --> 05:16.040 Here I used Lambrix as a length of this, published every. 05:16.970 --> 05:23.870 Here is a question if the length of an era belongs to compile time, then how could I use the land function 05:23.870 --> 05:24.110 here? 05:24.890 --> 05:27.140 Please post the video and try to answer. 05:36.760 --> 05:43.150 OK, it works because when you pass a constant to the land function, the land function also returns 05:43.150 --> 05:43.730 are constant. 05:44.440 --> 05:49.690 So when you compile your code, go will seem to replace this land books with four. 05:50.500 --> 05:54.820 So in the end, this just creates a Boolarra with four elements. 05:55.660 --> 05:56.140 All right. 05:57.040 --> 06:03.730 OK, they're published their first book, so let's set the first element to true like this. 06:04.710 --> 06:12.510 Remember, published Erra only contains Boulle elements, its element type is Boulle, right, so that's 06:12.510 --> 06:14.940 why I can set it to a bool value here. 06:16.020 --> 06:18.060 They also published the last book. 06:18.420 --> 06:20.160 Let's set it to true as well. 06:20.880 --> 06:22.890 First, I'm going to type Landmark's. 06:24.560 --> 06:31.490 Then I'm going to type minus one, so this will get the last element, OK, and lastly, I'm going to 06:31.490 --> 06:34.470 set these last element to true good. 06:34.730 --> 06:37.280 Now let's print only the published books. 06:38.610 --> 06:40.830 First, I'm going to create a header like this. 06:44.460 --> 06:47.100 Then I'm going to arrange over the published array like this. 06:48.620 --> 06:53.810 All right, I only want to print the published books, so I'm going to type and if Glozier. 06:55.070 --> 07:01.550 Remember this OK, variable, it cools to the next bool element inside the published area, right? 07:02.530 --> 07:09.340 And now I'm going to print a published book like this, let me type elsewhere here for the book's title, 07:10.000 --> 07:13.420 then I'm going to get the book from the book using the index variable. 07:14.170 --> 07:19.390 I can do this because the length of the published and the books are a lot of the same. 07:19.900 --> 07:22.020 All right, let's run this code now. 07:22.570 --> 07:27.850 Put it on the prints, the first and the last looks because only they have been published. 07:28.260 --> 07:28.760 All right. 07:28.780 --> 07:29.940 This lecture answer. 07:30.370 --> 07:31.830 Thank you for watching so far. 07:32.140 --> 07:33.220 See you in the next lecture.