Junior — Middle
Kus mälus asub objekt, mis on loodud funktsiooniga Make?
sobes.tech AI
Vastus AI-lt
The make function in Go is used to create slices, maps, and channels. Objects created with make are always placed in the managed heap because they require dynamic memory allocation for their internal structure (e.g., an array for a slice or a hash table for a map).
Example:
s := make([]int, 10) // slice of 10 elements
Here, a slice is created that contains a pointer to an array in the heap, and the slice itself is a structure with a pointer, length, and capacity. Therefore, the data the slice refers to is stored in the heap.