Why the capacity showing 14 in last line

 arr := [5]int{10, 20, 90, 70, 60}
        slice := arr[:3]
        fmt.Println(cap(slice)) //5

        slice_2 := make([]int, 10, 10) 
		fmt.Println(slice_2)
        new_slice := append(slice, slice_2...) //[10 20 90 0 0 0 0 0]
		fmt.Println(new_slice)
        fmt.Println(cap(new_slice))

Why cap is 14 ? as per lecture, capacity should get doubled if underlying array is smaller i.e. 5*2=10

fmt.Println(cap(new_slice))

There is quite a complicated algorithm behind slice reallocation once you exceed capacity. Contrary to what the course video says, it doesn’t always double the capacity when the slice needs to be grown.

Hi @sharmamitul72

I have now produced a detailed write-up on how slices work.