Merge pull request #1 from AnruKitakaze/fix-20-update-old-array-in-image-4

fix(#20): update img 4 and text for append
This commit is contained in:
Anru 2025-07-16 01:08:46 +07:00 committed by GitHub
commit 89c5e342f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 1 deletions

View file

@ -67,7 +67,7 @@ If we run this code, we see that the slice was able to cope with our request:
[0 1 0 2 3 4 5]
```
Because an array is a fixed-size structure, it can store the new elements until element 4. When we want to insert element 5, the array is already full: Go internally creates another array by doubling the capacity, copying all the elements, and then inserting element 5. Figure 4 shows this process.
Because an array is a fixed-size structure, we cannot fit all the new elements, since there isnt enough space for element 5. Go detects this in advance, creates another array with doubled capacity, copies the existing elements, and inserts all the new ones. Figure 4 illustrates this process.
<figure markdown>
![](img/slice-4.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB