So, Slice is a data type that you don't see in a lot of other languages. Slice is a really useful data type. So, a lot of times actually, slices are used instead of arrays, because they are flexible, you can change their size, you can increase them in size. So, let's talk about slices and how they're defined. Basically, a slice is a window on an underlying array. So, for every slice, there's going to be some underlying array that is the basis for the slice. The slice is just a window of it, a piece of it. So, you've got a long array of 100 elements, the slice is just maybe just three, four and five or something like that, or elements five, six, seven, eight, and nine, something like that. That's basically what a slice is, a window on a possibly larger array. It doesn't have to be larger, the array can be the same size as the slice. Then, the slice is just looking at the entire array, but the array can be much bigger than the slice and the slice can be just a smaller window on it. So, that's essentially what a slice is. So slices can have variable size, up to the size of the array. This is one thing that's really nice about slices, you can increase the size of the slice. An array is a fixed size thing. So, let's say I have an array of size 100 and I have a slice of size 10, which on that array and it's the first 10. I can increase the size of the slice to 20, and just look at the next 10 elements in the array and then I can increase to 30 and include the next 10 elements in the array. So, slices, you can increase the size of the slice, where you can't do that to an array. So, that's a good feature of slices. Now, every slice has basically three properties. One is the pointer that indicates the start of the slice. So every slice, since it's a window on an array, has to point to some element of the array that is the first element that is included in the slice. That's the point. The next thing in a slice, that's property of a slice, is its length, it's the number of elements in the slice. Because they all have a length. The third is the capacity. So, the capacity is the maximum number of elements in the slice. Now, that's defined by looking at the pointer which is the beginning of slice and looking at the difference between that and the size and the distance to the end of the whole array. Because a slice, it's size can be increased up to the size of the whole, up to the end of the array. So for instance, say you've got an array of size 100, you got a slice the size 10. You can increase that slice's size, say the slice starts right at the beginning of the array, you can increase the slice size all the way to 100, if you want to. So it has a capacity of 100. But, say you got an array of size 100 but this slice starts at array index 10, then it can only be increased to size 90, because by then you reach the end of the array. So the capacity of that slice is small. So, let's look at an example to see what I mean by these things. Slice examples. So, first we start with the underlying array. We got this array, we define it with this literal, it's got a, b, c, d, e, f, and g. That's the array, array of strings. Now, then we defined two slices on this, with that array as the underlying array, s1 and s2. Now, here's how we define these slices. We use this bracket notation, we use a colon inside the brackets to define the beginning and the ends of the slice. So, if you look at s1, s1 colon equals array, arr, bracket one colon three. The one is the pointer to the first element of the array, that is inside the slice, and the three is the index just after the end of the slice. So, that slice, s1, it includes array elements one and two, not three. So, the second number after the colon is just after the end. Now, if we look at s2. S2 colon five. Right, so S2 start at two. It include three and four, does not include five. So, we could see the picture down here at the bottom. You got the array in blue, the whole array. It has the a, b, c, d, e, f, g. Then in red, I've highlighted s1 and s2. So, s1, it includes index one and two because one colon three, so three is just past one past the N, and s2 includes two, three and four, and notice that these two slices overlap, and that's okay. If you look at s1 and s2, they both include array index two, and that's fine. Slices can overlap and refer to the same elements inside the underlying array. All right. So, the length and capacity, so there are two functions len and cap, which return the length and capacity of a slice. So, we got our array a1 here, and it's three elements long; a, b, c. Then, we define a slice, sli1 I'm calling it this time, and that is the array zero colon one. Okay. So, that means that this slice includes array index zero but not array index one. So, its length is actually one, should be one. It only has one element in it, array index zero. So, now the next statement, we do the print same. We print the length and the capacity. The length is one. Zero, zero is the only thing that's actually in the slice, but its capacity is still three, because its size could increase up to three if were to increase the size of the slice to go all the way to the end of the array since the array has three elements in it, and we are starting the slice at the beginning at array index zero, we could go all the way through array index zero, one, and two and the length of the slice could be up to three. So its capacity is three. Now, accessing slices or really referring to slices. So, when you write to a slice, to an element in a slice, you are writing to the underlying array. Overlapping slices can refer to the same array elements. So, you change one slice, you can change the underlying array, and you can change any of the slice that also accesses that, it also includes that array element. So, here we've got these in this picture, we show in this array. We got s1 and s2 are two different slices defined on it. See, in green, a circle that array element two, with the letter of the string c. So, that one is actually including s1 and s2. Now, in s1 with respect to s1, that is the s1 bracket one. It refers to that second element of the array, because s1 zero would refer to the first element of the array, because that's where s1 starts. So, s1 bracket one refers to that c, that letter c. Now, s2, that second element of the array, is the first element in s2. So, that's the same as s2 bracket zero. So, these two print statements will print the same thing, the letter C, because s1 bracket one is the same as s2 bracket zero. They're both referring of the same elements in the underlying array. Now, we talked about array literals, you can also have slice literals. They can be used to initialize the slice, just like an array literal can be used to initialize an array. Now, remember that every slice has to have an underlying array. So, when you initialize a slice, that means you're creating an array. You have to create the underlying array and the slice just covers the entire array. So, when when you use a slice literal to define a slice, it actually creates an underlying array and it creates a slice to reference the entire array. So, the length and the capacity of the slice are the same. So, if you do this, if you use a slice literal to create this array, its pointer will point to the beginning of the array and its length will be the length of the array and its capacity will also be the length of the array. So, the slice points to the entire array when you use a slice literal to define in this way. So, we can see that here, we're defining it using a slice literal. SLI is defined as a slice literal and it defines the underlying array. You know that this is a slice literal because you can see where I say sli colon equals brackets. Normally, in the brackets you'd put the length if it was an array, or put five or three in this case or you'd put least dot dot dot to say this is an array, it's length should be inferred from the number of elements inside the curly brackets. But in this case, we didn't put anything in the brackets. So, the compiler says," Oh this must be a slice," and what it does is it creates the underlying array and then it makes a slice point to the whole array.