Grokking Go
0% completed
Create a Slice With "make()" Function
In Go, slices can be created using the make() function, which allows allocating memory for a slice dynamically. This method provides more control over memory allocation and is useful when the size of a slice is not known in advance.
Unlike slices created from arrays, slices created with make() do not need an existing array. Go allocates a new underlying array for them internally.
Understanding the Components of a Slice
A slice in Go consists of three main components:
- Pointer → Points to the first element of the underlying array.
2
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%