Welcome back.
Okay let's remember the composite types once more. In the last section you've learnt about arrays. Remember
an array's length is fixed. So you cannot change it after you compile your code.
In this section, you're going to learn about slices. Slices are dynamic arrays of Go.
So you can add new elements or you can remove the existing elements from a slice but a slice doesn't
store any elements itself. It is just a window to an array.
Don't worry, in this very comprehensive section you're going to learn everything about slices.
Now let's take a look at what you're gonna learn in this section.
First, we'll start by looking at the differences between a slice and an array so you'll better understand
what a slice is. After that, you're going to learn how to grow a slice using the append function.
After learning how to grow a slice, you'll learn how to slice a slice. Slicing is a way to shrink a slice.
By slicing
You can create smaller subsets of another slice.
After that, we will go deeper and you're going to learn what a slice actually is.
You'll learn about the backing array, the slice header and the capacity of a slice.
This knowledge will allow you to use the slices more creatively and without fear.
And it will prevent you from making the well-known beginner mistakes. With the knowledge of the slice
internals like the backing array and the capacity,
you'll be able to learn how the full slice expressions work. A full slice expression allows you to limit
the capacity of a slice.
And after that, you'll learn how to pre-allocate a slice using the make function. The make function allows you
to create a slice with the given length in the runtime.
It is there for optimization (mostly).
So that's why you're going to learn it at the last, and it's also because using the make function properly
requires you to know the internals of the slices.
And after that, you're going to learn how to copy the elements of a slice to another slice without using
a loop.
And lastly, you're going to learn how the multidimensional slices work.
Now let's talk about the projects that we're going to build.
The first project that we're going to build is an empty file finder.
It will be your first project that works with files.
When you run it like so, its prints to empty the files in a given directory.
It also saves the result to a file.
You're going to use the power of slices to create this project. The next project that we're gonna build
is called the bouncing ball.
You'll create a grid using a multidimensional slice.
After that, you're going to create a ball that jumps inside this grid like so. Don't worry though,
these are not the only projects. Throughout the course you will see more examples.
Slices are very important in Go programming. So, that's why I've created the most comprehensive slice
explanation you can ever find.
See you in the next lecture.
Bye for now.