mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-21 00:47:11 +08:00
fix(#20): update img 4 and text for append
This commit is contained in:
parent
d21c8462b1
commit
42c11de062
2 changed files with 1 additions and 1 deletions
|
|
@ -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 isn’t 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>
|
||||

|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.4 KiB |
Loading…
Reference in a new issue