WEBVTT 0 00:01.590 --> 00:03.200 Welcome back. 1 00:03.220 --> 00:11.190 Okay let's remember the composite types once more. In the last section you've learnt about arrays. Remember 2 00:11.400 --> 00:16.450 an array's length is fixed. So you cannot change it after you compile your code. 3 00:16.710 --> 00:22.320 In this section, you're going to learn about slices. Slices are dynamic arrays of Go. 4 00:22.920 --> 00:29.280 So you can add new elements or you can remove the existing elements from a slice but a slice doesn't 5 00:29.280 --> 00:33.690 store any elements itself. It is just a window to an array. 6 00:34.020 --> 00:39.300 Don't worry, in this very comprehensive section you're going to learn everything about slices. 7 00:39.300 --> 00:42.280 Now let's take a look at what you're gonna learn in this section. 8 00:42.360 --> 00:48.840 First, we'll start by looking at the differences between a slice and an array so you'll better understand 9 00:48.900 --> 00:55.840 what a slice is. After that, you're going to learn how to grow a slice using the append function. 10 00:56.070 --> 01:03.030 After learning how to grow a slice, you'll learn how to slice a slice. Slicing is a way to shrink a slice. 11 01:03.180 --> 01:04.130 By slicing 12 01:04.140 --> 01:07.710 You can create smaller subsets of another slice. 13 01:07.710 --> 01:12.670 After that, we will go deeper and you're going to learn what a slice actually is. 14 01:12.690 --> 01:18.030 You'll learn about the backing array, the slice header and the capacity of a slice. 15 01:18.090 --> 01:23.020 This knowledge will allow you to use the slices more creatively and without fear. 16 01:23.100 --> 01:28.710 And it will prevent you from making the well-known beginner mistakes. With the knowledge of the slice 17 01:28.710 --> 01:31.650 internals like the backing array and the capacity, 18 01:31.680 --> 01:38.610 you'll be able to learn how the full slice expressions work. A full slice expression allows you to limit 19 01:38.610 --> 01:40.480 the capacity of a slice. 20 01:40.890 --> 01:47.400 And after that, you'll learn how to pre-allocate a slice using the make function. The make function allows you 21 01:47.400 --> 01:50.970 to create a slice with the given length in the runtime. 22 01:51.060 --> 01:52.750 It is there for optimization (mostly). 23 01:52.860 --> 01:58.170 So that's why you're going to learn it at the last, and it's also because using the make function properly 24 01:58.320 --> 02:02.160 requires you to know the internals of the slices. 25 02:02.160 --> 02:07.890 And after that, you're going to learn how to copy the elements of a slice to another slice without using 26 02:07.890 --> 02:09.370 a loop. 27 02:09.390 --> 02:13.650 And lastly, you're going to learn how the multidimensional slices work. 28 02:13.650 --> 02:16.940 Now let's talk about the projects that we're going to build. 29 02:17.010 --> 02:21.070 The first project that we're going to build is an empty file finder. 30 02:21.120 --> 02:24.300 It will be your first project that works with files. 31 02:24.330 --> 02:30.820 When you run it like so, its prints to empty the files in a given directory. 32 02:30.840 --> 02:33.400 It also saves the result to a file. 33 02:33.450 --> 02:40.220 You're going to use the power of slices to create this project. The next project that we're gonna build 34 02:40.220 --> 02:42.680 is called the bouncing ball. 35 02:42.740 --> 02:46.360 You'll create a grid using a multidimensional slice. 36 02:46.460 --> 02:52.590 After that, you're going to create a ball that jumps inside this grid like so. Don't worry though, 37 02:52.670 --> 02:57.730 these are not the only projects. Throughout the course you will see more examples. 38 02:58.040 --> 03:03.830 Slices are very important in Go programming. So, that's why I've created the most comprehensive slice 39 03:03.830 --> 03:06.160 explanation you can ever find. 40 03:06.200 --> 03:07.390 See you in the next lecture. 41 03:07.400 --> 03:08.090 Bye for now.